98

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.

Paresh Mangukiya
  • 37,512
  • 17
  • 201
  • 182
Masroor
  • 1,324
  • 1
  • 11
  • 19
  • 2
    Do you have play services enabled? – Drei Apr 20 '18 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 '18 at 08: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 '18 at 23:27
  • Hey I am getting the same issue but didn't solved it by--> Turn Off the "Restrict Cellular Data Access" option . Any help will appreciated. Thanks. – TechValens Sep 03 '18 at 06:03
  • 2
    Restart your phone....worked for me .. – James Jul 10 '18 at 19:32
  • 1
    Enabling only one type of network connection (wifi or lte) worked for me. – shadowsheep Feb 27 '19 at 10:38
  • Restarted phone.. worked for me.. – SoftSan Dec 26 '19 at 19:05

13 Answers13

98

"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

28

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

cowboycb
  • 509
  • 4
  • 11
21

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

gabhor
  • 579
  • 8
  • 22
9

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

EdHuamani
  • 1,729
  • 11
  • 16
9

To fix it you should check your Google play services properly are enabled

If it is still showing the same error then you need to try the below steps

  1. You need to stop your emulator device.

  2. After that you need to open the AVD Manager Panel then the edit device configuration. In your device configuration panel go to "Show Advanced Settings" in the "Emulated Performance" section then you need to select the "Cold boot" option as the Boot Option then you should click on the Finish.

After following the above steps your issue related to firebase must be fixed and it should be working.

Paresh Mangukiya
  • 37,512
  • 17
  • 201
  • 182
6

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.

NanPd
  • 710
  • 7
  • 14
5

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

Mo Meshkani
  • 1,306
  • 1
  • 14
  • 26
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

Anupam Haldkar
  • 777
  • 10
  • 15
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

Quang Le
  • 331
  • 3
  • 8
0

You could be using a deprecated version of Google Play Services on your device, try upgrading your Play Services first.

0

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.

MrPlow
  • 1,127
  • 9
  • 7
0

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

Akash Neeli
  • 154
  • 7
0

Visual Studio 2022 menu:

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

enter image description here