37

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)
Lenin Raj Rajasekaran
  • 20,773
  • 12
  • 92
  • 131
Razvan Cristian Lung
  • 4,032
  • 2
  • 20
  • 43
  • Does the package name match? – Ziya ERKOC Aug 16 '17 at 07:10
  • Yes. It works on a real device. Note the last part of the error: [ App validation failed. Is app running on a physical device? ] – Razvan Cristian Lung Aug 16 '17 at 07:11
  • 1
    I got it. It is probably occured since emulators do not have google play service which is a necessity for firebase to work – Ziya ERKOC Aug 16 '17 at 07:15
  • @ZiyaERKOC I'm using an image with Play Store installed – Razvan Cristian Lung Aug 16 '17 at 11:41
  • Why is this down voted? – Razvan Cristian Lung Aug 25 '17 at 18:14
  • Hi did you solve it ? – Fayçal Sep 11 '17 at 17:56
  • Hi, I am facing a rather Unique problem here. I am using FirebaseUI for Authentication. I have enabled PhoneAuth and Googlel Auth for authentication in Firebase console. Problem is that Google Auth is working fine but PhoneAuth is giving error: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.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 ] – Krups Sep 25 '17 at 09:59
  • @Krups do you run the app in the emulator or physical device – Razvan Cristian Lung Sep 25 '17 at 20:56
  • @RazvanCristianLung I was running app on physical device. Thanks for your comment but i have solved the issue now. – Krups Sep 26 '17 at 07:22
  • @Krups let me guess: debug version is not signed by default? – Karol Kulbaka Jul 21 '18 at 17:29
  • what was the problem @RazvanCristianLung, i have the same problem, i stay work on phisical device, my autentication for facebook and firebase works ok i linked my app with play store, i get my sha1 for cmd and singin report, i went to tools firebase autentication and sing in but not working please help, sorry for my english! the problem is only with PhoneAuthProvider – Dave Rincon Aug 14 '19 at 23:52

12 Answers12

63

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

Prasanna Anbazhagan
  • 1,540
  • 17
  • 33
23

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

Felix Cruz
  • 1,447
  • 19
  • 22
  • 2
    Worked like charm !! Thanks :) – Anjana Apr 02 '20 at 09:50
  • 1
    TY! I was using device for testing (not emulator). This was the only thing I found that solved this error: FirebaseUiException: There was an error while trying to get your package certificate hash. – wakeupoj Jul 27 '20 at 04:24
12

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.

Razvan Cristian Lung
  • 4,032
  • 2
  • 20
  • 43
10

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 Setup > App Integrity. 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:

enter image description here

Now Save Changes then Go back to your App and test it again it will work now!.

Abdul Wahid
  • 461
  • 5
  • 10
Yeuni
  • 228
  • 3
  • 6
7

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:

enter image description here

Also make sure you are using a release keystore to generate this key

enter image description here

enter image description here

After this generate your SHA1 fingerprint else your users will face SHA1 error on phone authentication.

Hope it help somebody.

Hitesh Sahu
  • 31,496
  • 11
  • 150
  • 116
6

You need to configure the SHA-1 in firebase console.

You can do it very easily using Android Studio tools.

  1. Open Tools -> Firebase in Android Studio.
  2. Click any one of the feature, like Authentication or RealtimeDatabase.
  3. 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

Ritesh
  • 2,558
  • 2
  • 15
  • 38
1

For me the problem was simply that I was working on an emulator entering a phone not saved as a test phone number (Firebase->authentication->sign in method->Phone-> and add a test phone number here

Simon
  • 4,844
  • 4
  • 32
  • 69
0

Generate SHA-1 certificate prefer this link SHA-1 fingerprint of keystore certificate
enter image description here

after open your firebase console and add this SHA-1 Key here.

Kishan Donga
  • 1,813
  • 15
  • 27
0

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.

enter image description here

According to @adirzoari open your react native project into android studio and then:

  1. Run your project.
  2. Click on Gradle menu.
  3. Expand Gradle Tasks tree.
  4. 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.

badarshahzad
  • 1,097
  • 14
  • 23
0

enter image description hereHow to fix please verify that the correct package name and sha1 are configured in the firebase console:

  1. Make sure add SHA in firebase in your app Klik Settings -> Project Settings -> General -> Add Fingerprint (SHA 1 in your app) -> Save

  2. And then Klik Authentication -> Sign-in method -> Phone -> Phone number testing (optional) -> Save

  • Provide the phone number you want to test, for example: +1 650-555-3434
  • Provide the 6-digit verification code for that specific number, for example: 654321 enter image description here
  1. Whoolaaaaa its work for me "Code been sent" in emulator enter image description here
0

Add SHA-1 without SHA-1 mentioning in it. Like you have SHA-1 as :

SHA1: 6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A

Add only this to firebase Project settings

6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A

For more info

You can generate SHA keys from gradle command

./gradlew signingReport

Sajid Zeb
  • 1,339
  • 15
  • 29
0

Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone . Add the random numbers with verification code toenter image description here "Phone numbers for testing (optional)" field.

Sonali
  • 1
  • 1