Home > Net >  Firebase doesn't work on Android Studio Emulator
Firebase doesn't work on Android Studio Emulator

Time:08-18

I was working on a project for my studies and everything was working fine, but I changed my OS to win11 while wiping all previous data.
Now Firebase is stuck on "loading" after using any type of sign in. Real time database data is not showing as well. After around 5-10 of waiting auth will sometimes work continuously (can sign in, sign out multiple times, until running app again) but database never.
Everything works well when i use physical device. Apps without firebase work fine on emulator. Internet connection works. Example app that doesn't work:
https://github.com/firebase/quickstart-android

I have:

  1. Used multiple different emulators(those with google play) with different sdk
  2. Changed SHA1 and google-servies.json
  3. In Settings -> Appearance & Behavior -> SDK Tools downloaded and activated Google play service
  4. Reinstalling Android Studio, installing win10 again
  5. Updated Google Play services version
  6. Tried different projects on different firebase accounts
  7. Activated Sign-in methods in firebase console
  8. Searched web for several hours and done many other things I can't even remember now

The only error I'm sometimes getting is:
E/FirebaseInstanceId: binding to the service failed
and this error when I use new emulator for the first time:
E/FirebaseMessaging: Topic sync or token retrieval failed on hard failure exceptions: java.util.concurrent.ExecutionException: java.io.IOException: AUTHENTICATION_FAILED. Won't retry the operation.
E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: AUTHENTICATION_FAILED. Won't retry the operation.
E/FA: Missing google_app_id. Firebase Analytics disabled.
E/FA: Uploading is not possible. App measurement disabled

For me it looks like something is blocking(or really slowing down) connection between android studio emulator and firebase.
I would be very grateful for any kind of help, its really important for my studies.

CodePudding user response:

The network speed on the emulator is slower than your real network speed, so try to switch to a faster network. I have been in your situation many times and solved it by switching 4G network, And one time I was on Governmental institute and found that their network was blocking firebase for some reason so make sure that the network connection is not the reason.

CodePudding user response:

What fixed my problem was installing an older version of android emulator form this website:
https://developer.android.com/studio/emulator_archive
I was using Android Emulator (31.3.10) Beta 1 and switching to Android Emulator (30.9.5) solved the problem.

  • Related