105

I'm working on an android app, it uses Firebase Authentication, Database and Storage. It was all working fine until this error message started to show up in logcat. (I did not tamper with any configs at firebase console)

E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE

this error message shows even when I have commented on all firebase-related code.

Therefore I'm unable to proceed with authentication and other firebase-related stuff.
Yes, I'm connected to the internet and also have gotten a new Google-Services.json file from Firebase Console but it has made no difference at all.

7
  • 2
    Do you have play services enabled?
    – Drei
    Apr 20, 2018 at 23:10
  • yes both Google play services and Google play store are enabled in my device. Any idea about what other issue could be? I've tried the same code on an android emulator and it worked. I don't know how my physical device got this problem, it worked fine before this.
    – Masroor
    Apr 21, 2018 at 8:18
  • 6
    so, I was able to resolve it finally! It turns out that Google play services were enabled, but they were restricted over Cellular Data. To solve it, I did the following: App Data Usage -> Google Services -> Turn Off the "Restrict Cellular Data Access" option
    – Masroor
    Apr 21, 2018 at 23:27
  • 2
    Restart your phone....worked for me ..
    – James
    Jul 10, 2018 at 19:32
  • 1
    Enabling only one type of network connection (wifi or lte) worked for me. Feb 27, 2019 at 10:38

13 Answers 13

101

"Cold Boot Now" Device in AVD Manager worked for me.

Edit: After updating emulators and than doing the cold boot it helped. – parohy Apr 5 at 9:22

7
  • 3
    After updating emulators and than doing the cold boot it helped.
    – parohy
    Apr 5, 2019 at 9:22
  • 1
    Cold boot did it for me. Thanks Feb 22, 2020 at 2:36
  • That was it all along!? Is there a specific reason this would fix the issue? Maybe having different applicationIdSuffixes with each flavor or something? Jul 9, 2020 at 8:29
  • This tip work for me too. Working with Flutter with an emulated devide on Android Studio. Oct 25, 2020 at 1:18
  • I went to the AVD Manager, click on device and then show advanced settings and finally i switched to "Cold Boot Now", then save and my issue was gone, thansk! Nov 1, 2020 at 6:30
29

Stop emulator device and open AVD Manager Panel, edit device configuration. In device configuration panel "Show Advanced Settings" in "Emulated Performance" section select "Cold boot" option as Boot Option then click Finish, it should be worked.

enter image description here

0
22

I also faced with this issue. As I can see it can happen for many reasons.

Finally I figured out that my problem was that the current latest Facebook Android SDK version (v4.36.0) has a bug. Everything works fine if I set it back to v4.35.0. Maybe this info can help someone in the future.

You can find here the releases: https://github.com/facebook/facebook-android-sdk/releases

5
  • 7
    Using com.facebook.android:facebook-android-sdk:4.36.0 caused white blank screen on loading of mine application. Changed to 4.35.0, fixed the problem. Thanks!
    – kashlo
    Sep 10, 2018 at 14:57
  • 1
    Wow! You just saved me!
    – orelzion
    Sep 15, 2018 at 19:12
  • I downgraded to v4.35.0 of FacebookSDK and that fixed the problem! Thanks a lot!
    – Mladen
    Sep 16, 2018 at 20:52
  • I was having the same issue in Android Q - API 29, and this fixed it. Thanks
    – andrey2ag
    Jul 29, 2019 at 22:20
  • It's glad to hear that! You can also try to upgrade to the latest one since it was already fixed in the upcoming versions.
    – gabhor
    Jul 30, 2019 at 11:33
9

you need to update the emulator to the latest version that includes Google Play services

0
7

For future readers:

Found this error when I set device date different than current and open. My application logs start printing similar log. Solution: restart your device and it will start working fine.

0
5

I changed my emulator and now it is working correctly without any error.

5

Check that Google play services are enabled

if it still shows error Now try these steps

Step 1 - Stop emulator device

Step 2 - open AVD Manager Panel, edit device configuration. In device configuration panel "Show Advanced Settings" in "Emulated Performance" section select "Cold boot" option as Boot Option then click Finish, it should be worked.

If this does not work try to work on different Emulator

4

In my case, I was facing an Internet connectivity Issue. Make sure your Internet Connection is Strong enough to Generate FcmToken.

1
  • 1
    Me too. Actually, I had weak WIFI and thought it would keep the connection stable. But this error kept coming. Apparently, that is the real issue. Thank you. Now I use mobile connection for this. I would never use that weak WIFI again.
    – Wege
    Mar 19, 2023 at 1:21
2

Visual Studio 2022 menu:

  1. Tools
  2. Android
  3. Android Device Manager
  4. Select device and click Edit

enter image description here

1

Root cause: You miss google services in your device. So if you use emulator then apply "Cold boot" mode in advanced setting, if you use real device please change another enter image description here

1

For me, this was a connection issue with my emulator. I was unable to load websites outside of my company's VPN. Probably worth confirming that you can do that (load up yahoo or stackoverflow on the device's browser) if you're having this issue. Once I figured out my emulator's connection issues, I was able to get the token.

1

wipe android emulator data and than run emulator its work for me enter image description here

0

The solution is so simple and You have to cold-boot your android emulator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.