4

I have an app that contains Google sign-in functionality and am using Firebase Authentication to do that.

Everything works perfectly when building directly to the device. However, after exporting the aab file and uploading it to Google Play Console for publishing, I tried downloading the signed apk file to install and realized that this login function did not work.

I wonder if anyone is having the same problem as me?

4 Answers 4

4

After many days of research, I realized what I encountered:

  1. Add SHA-1 and SHA-256 of App signing key certificate and Upload key certificate to Firebase. (Many people have probably seen this suggestion on many easily searchable answers)
  2. REMEMBER "Link Cloud project" at Google Play Console > App Integrity > Play Integrity API. Select the firebase project you created and add SHA in step 1 above then submit.

Everything works like a charm. xD

Sign up to request clarification or add additional context in comments.

Comments

2

Simple fix:

  1. Go to Play Console → Setup → App Signing, copy the SHA-1 and paste it into Firebase Console > Project Settings > Android App.

  2. Download a new google-services.json after adding the key and add it to your app.

  3. Go to Play Console → App Integrity → Link project, and link your Firebase project.

That’s it. Worked like a charm after publishing!

Comments

1

This is just for a person having an issue with phone auth not working. I had a similar problem maybe one of you could also be having this issue. I have added SHA properly and everything was working fine. I have even generated a Signed APK and it was working fine but when I publish it to Play Store it just gives an error after I enter OTP and hit verify. After multiple Internal releases were pushed to Play Store I directly logged the error and found the exception firebase_auth/session-expired. Came to know that the user's is OTP is automatically verified and the user is logged in, when OTP is used for logging in clicking on verify again gives an error.

Here is code that will also help you fixing the please use you logic here too instead of just codeSent callback.

verification completed: (PhoneAuthCredential credential) async {
  await FirebaseAuth.instance.signInWithCredential(credential);
  // do whatever you want 
  //save details and navigate to next screen
},

Comments

0

If everything failed (and when I say everything I mean e v e r y s i n g l e t h i n g) it may be that the Firebase have not generated correctly the google-services.json for some reason. That was just what happened to me. Removing and re-adding the keys on Firebase will solve it.

The secret to debug any of this mess is to get your phone with the app from the PlayStore installed, connect it to your PC and logcat the stuff with something like (substitute completely <ADBDEVICENAME> and <APPNAME> including <>):

adb -s <ADBDEVICENAME> logcat | grep <APPNAME>

and then look for:

[GetTokenResponseHandler] Server returned error: Invalid key value: <SOMEHASHHERE>

What you're looking for is to see what is being done wrong, because in this line the logcat will spew a hash that can be converted to HEX so you can actually compare within your code if it is a debug key or if it is a key coming from the Play Console that is on Firebase but not on the google-services.json and so on.

New contributor
metabee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.