"This app is not authorized to use Firebase Authentication" in Emulator

I'm getting this error when I try to run my app on emulator.

What I've done:

  1. I'm using Firebase-UI and running Android O
  2. I have the Play Store updated.
  3. I've added all the SHA-1 code to Firebase console and the package name matches.

In fact when I run the app on a real device it runs perfectly and I can login.

This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console.
 com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed. Is app running on a physical device? ]
 at com.google.android.gms.internal.jz.zzK(Unknown Source:239)
 at com.google.android.gms.internal.kp.zza(Unknown Source:2)
 at com.google.android.gms.internal.kq.run(Unknown Source:37)
 at android.os.Handler.handleCallback(Handler.java:789)
 at android.os.Handler.dispatchMessage(Handler.java:98)
 at android.os.Looper.loop(Looper.java:164)
 at android.app.ActivityThread.main(ActivityThread.java:6541)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

In order to prevent abuse the firebase phone authentication wont work in emulator.

But if you want it for testing purpose then you should add use some testing phone number in firebase console that will work in emulator.

Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone and check the "Phone numbers for testing (optional)" field.

enter image description here


sha1 generation in android studio:

Select Gradle in android studio from right panel

Select Your App

In tasks -> android-> signingReport

Double click signingReport.

You will find the sha1 fingerprint in the "Gradle Console"

add this sha1 fingerprint in firebase console


OK, so it is a documented error. https://github.com/firebase/FirebaseUI-Android/issues/790 and https://github.com/firebase/FirebaseUI-Android/issues/868

in order to prevent abuse you can't user Phone Auth on an emulator.

docs are here: https://firebase.google.com/docs/auth/android/phone-auth#before-you-begin

Also, note that phone number sign-in requires a physical device and won't work on an emulator.

UPDATE Take a look at Prasanna Anbu's answer.