When running Firebase Messaging based app under Android emulator, if we are getting the error
W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
, this most likely means that the fcm messaging token retrieval failed due to inability to connect to the server. Check the internet connectivity inside the emulator. I was running the app with iPhone Hotspot and the emulator had no internet connectivity. Once the connectivity issue got resolved, the token generation succeeded.