问题
I'm getting this error when I try to run my app on emulator.
What I've done:
- I'm using Firebase-UI and running Android O
- I have the Play Store updated.
- 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)
回答1:
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.
回答2:
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.
回答3:
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
回答4:
You need to configure the SHA-1 in firebase console.
You can do it very easily using Android Studio tools.
- Open
Tools -> Firebase
in Android Studio. - Click any one of the feature, like
Authentication
orRealtimeDatabase
. - Click on the
Connect to Firebase
and do the required.
or
Add it manually. Check out this..
How to add SHA-1 to android application
回答5:
Your SHA1 key is not registered in your firebase console. Simply generate SHA key as shown in pic below, copy the SHA key from Android Studio terminal and add it in Firebase console project settings:
Also make sure you are using a release keystore to generate this key
After this generate your SHA1 fingerprint else your users will face SHA1 error on phone authentication.
Hope it help somebody.
回答6:
After spending the whole Day figuring out what was the issue. I’ve found the culprit! It was in the App Signing for Google Play that we have opted-in.We need to register the SHA-1 from the App Signing itself. It can be found in the inside Google Play Console under Release Management > App Signing. It will have two types of certificate: 1.Upload certificate: this is the information of the certificate from the keystore that uploaded. This is needed to be the same with the keystore for app signing locally as the Google Play will verify the uploaded app to match with this signed certificate.
2.App Signing certificate: after uploaded the app, Google will replace the upload certificate with this certificate. This is a new certificate that will be used for published app in Play Store.
With those information, I just realize that we hadn’t registered the SHA-1 for the App Signing certificate which being used by published app. So, I added the SHA-1 (also the SHA-256, just in case needed) fingerprints in the Firebase > Project Setting for the app (Don’t forget to update the latest config file after added the fingerprints).
So After adding your your SHA Fingerprints your Firebase SHA certificate fingerprints will look like this:
Now Save Changes then Go back to your App and test it again it will work now!.
回答7:
Generate SHA-1 certificate
prefer this link SHA-1 fingerprint of keystore certificate

after open your firebase console and add this SHA-1 Key here.
回答8:
I was also facing the similar issue in react-native build as show in the below picture. I solved the problem by following the below mentioned steps.
According to @adirzoari open your react native project into android studio and then:
- Run your project.
- Click on Gradle menu.
- Expand Gradle Tasks tree.
- Double click on android -> signingReport and you'll see the result
For Android studio 2.2 - result will be available under Run console but use highlighted toggle button.
来源:https://stackoverflow.com/questions/45707173/this-app-is-not-authorized-to-use-firebase-authentication-in-emulator