97

I went through this, and as far as the process goes I did that.

But I when I installed the app from play store I am not able to sign in using the google sign in button.

I have used Firebase for google sign in. When I am clicking the sign in button the option to choose the account is coming but then it is not signing in or doing anything.

So where possibly am I going wrong?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
arqam
  • 3,582
  • 5
  • 34
  • 69

14 Answers14

302

When you upload an apk to the play store then play store creates a new SHA1 key called "App signing certificate". You get that SHA1 and save in your console or firebase account (as you need).

New SHA1 will be found at Released Management->App Sigining on your play console.

[enter image description here]

Prinkal Kumar
  • 3,196
  • 2
  • 10
  • 15
  • 3
    @PrinkalKumar after uploading an apk to playstore, and adding SHA1 of App signing to firebase console with debug SHA1. Do I need to re-download the google-services.json file and publish the signed apk again? Do reply. – Pankaj Lilan Aug 03 '17 at 04:46
  • 5
    @PankajLilan No , You added your SHA1 thats enough. But for better result re-download and save .json file .So this will be used on next update of your app. Firebase only use your package name string from .json file and it will check all VALID SHA1 from its console itself. So if package name is same ,only SHA1 is different ,there is no need to re download google-serveice.json file again. Hope this will help – Prinkal Kumar Aug 04 '17 at 05:34
  • 5
    You saved my life. They should have a proper documentation regarding this. How did we miss this issue. This works perfectly. This answer should be mentioned as the correct answer! – tor9ado Aug 30 '17 at 12:33
  • 1
    Thank you.. For Gmail API auth2.0 signin certificate this will also work. we should NOT use upload certificate , but use signed certificate. – Learning Always May 19 '18 at 07:03
  • Thanks so much for this. But just where is this burried in the documentation?? – Crocodile Sep 12 '18 at 14:00
  • 1
    works, but for release only. If I upload app in internal test track, it still breaks. – Vaibhav Vishal Jan 24 '20 at 06:01
  • internal test track and release uses different keys. I got test track keys from `App Certificate` Section of internal test track, wasn't too hard to find. Sorry for posting a comment before trying to find the keys in play console – Vaibhav Vishal Jan 24 '20 at 06:54
  • I know i am late but for Gmail API auth2.0, i used the App signing certificate in the Google API console and it works fine. But if i want to debug my app in android studio, it doesn't work. How do i do this ? – Mervin Hemaraju Jun 07 '20 at 17:13
  • 1
    On latest version of Google Play, App signing key certificate is located under: `Release -> Setup -> App Signing` – mDonmez Dec 10 '20 at 18:42
  • 9
    Now it is found under: Release -> Setup -> App Integrity -> App signing key certificate – Mr. Messy Apr 19 '21 at 22:21
  • in recent is there any update? i copy sha1 from app signing but it not working in play store download, but working on debug mode. thanks. – Saied Islam Shuvo Nov 11 '21 at 12:24
  • @SaiedIslamShuvo App siging is absolute and there is no change on this process. I recommend you check your SHA keys once again. It might be possible that you missplaced something. – Prinkal Kumar Nov 13 '21 at 08:08
  • @PrinkalKumar it works before added firebase, after added firebase its not working, and don't wanna use firebase for google auth, i used firebase for fcm, what can i do? thanks. – Saied Islam Shuvo Nov 13 '21 at 08:39
  • @SaiedIslamShuvo "What is not working" , could you please share more detail now. – Prinkal Kumar Nov 13 '21 at 09:06
  • @PrinkalKumar google sign in not working, it throw PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) – Saied Islam Shuvo Nov 13 '21 at 10:35
  • @SaiedIslamShuvo Try to add support email in the Settings -> General -> Public Settings. and check if it works. – Prinkal Kumar Nov 13 '21 at 10:46
  • @PrinkalKumar its not working, it works on debug mode, but I had putted app signing sha1 in google cloud console – Saied Islam Shuvo Nov 13 '21 at 11:28
  • "but I had putted app signing sha1 in google cloud console" SHA1 should be on your firebase console – Prinkal Kumar Nov 13 '21 at 22:08
43

Update: Google changed behaviour of uploading APK, check answer below!

Release APK and debug APK has different SHA1 and different API keys for google services. Both of them must be added in Firebase Console -> Project settings. Then download google-services.json from here, add it to project and recompile with release keystore using option "Build signed APK". That should work

Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86
  • @DimaRostopira Can you please explain me how to add "API Keys" for debug and release mode? i have created project in firebase console. – Maulik patel Sep 01 '17 at 13:34
  • 2
    @Maulikpatel behaviour has changed, check answer below – Dmytro Rostopira Sep 02 '17 at 12:57
  • I have also generated sha1 for release apk but still after publishing the app on play store google login not working, – Lovekush Vishwakarma Sep 22 '17 at 06:15
  • @LovekushVishwakarma check answer below. You should also add SHA1 for key generated by Google Play Developer Console in **Released Management->App Sigining** – Dmytro Rostopira Sep 22 '17 at 09:45
  • @DimaRostopira Please check my issue at https://stackoverflow.com/questions/55235295/google-signin-working-in-release-apk-but-not-on-play-store?noredirect=1#comment97203989_55235295, its a completely different scenario from here – Shikhar Mar 19 '19 at 07:14
41

The problem was created when Google Play App Signing was enabled for my app. Google Play App Signing changes the SHA-1 certificate fingerprint (from what is in my keystore) to their own SHA-1 certificate fingerprint.

The fix:

  1. Goto https://play.google.com/apps/publish/
  2. Click your application >> Release Management >> App Signing.

You will see "App signing certificate" and "Upload certificate"

  1. Copy the SHA-1 From "App Signing Certificate." (THE TOP ONE)
  2. Goto https://console.firebase.google.com/
  3. Click your application >> Settings [Gearbox Icon to the right of project overview] (top of the screen) >> Project Settings >> General [Tab] >> Add Fingerprint
  4. Paste the SHA-1 App Signing Certificate. Save.

All fixed!

Alan Nelson
  • 1,129
  • 2
  • 11
  • 27
17

There are three types of SHA1 is required for an app lifecycle when you are using firebase

  • -debug SHA1
  • -release SHA1
  • -signing SHA1 (it getting from play store)

You need to add signing SHA1 to firebase after publish your application here i am attaching two screen shots please have a look . The red marked certificates is must be required, so copy it from playstore and paste it on firbase enter image description here

enter image description here

In firebase paste here

Muhammed Fasil
  • 7,909
  • 2
  • 19
  • 28
14

In the latest Google play console 2022:

QUICK GUIDE:

Application Play console > Setup > App Integrity

OR
Search App Integrity in application's Search box

DETAILED GUIDE:

Step 1: Go to https://play.google.com/console/u/3/developers and open your application's Dashboard

Step 2: On the left sidebar under Release, select Setup, then App Integrity.

Optional: You could also simply search App Integrity in the Search.

enter image description here

Brian
  • 406
  • 1
  • 5
  • 8
12

Issue happens because

1) when you create / publish an app through google play console, there is an option for enable Google Play App Signing. if you enable it will show

Google Play App Signing is enabled for this app.

enter image description here

then your Upload certificate details will change and you need to rewrite SHA-1 etc. certificate details in respective places.

2) You provided debug key store / SHA-1 certificate details instead of RELEASE certificate details

3) error while generating certificates.

Solution

1) Go to google play console

Relese management -> App signing

then you can see two types of certificate

1- Upload certificate ( your app certificate provided when generating signed apk)

2- App signing certificate ( because you enabled Google Play App Signing, so they provided new certificate details for your published apk)

you need to change uploaded certificate details with new details provided by google play where ever you used it before. such as Integrating google sign in (change SHA-1 of OAuth client), facebook login (change key Hash (generate key hash using SHA-1 use this link or copy the key hash provided by facebook login error screen), firebase etc.

2) provide release SHA-1 / keyHash

create / use Keystore details of signed apk.

using command prompt:

google / firebase SHA-1 :

keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v

facebook release key hash:

keytool -exportcert -alias <user alias name> -keystore < keystore path> | <openssl-path> sha1 -binary | <openssl-path> base64   

if asked for password enter your signed apk keystore password.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Adarsh Vijayan P
  • 2,964
  • 2
  • 16
  • 27
8

If someone is not able to solve this issue then just open Setup > app integrity in the console and then copy the SHA1 and paste in your firebase console.

enter image description here

Shivam Yadav
  • 958
  • 11
  • 23
7

To add on existing responses, once you have the newly created SHA1:

Goto https://console.firebase.google.com:

  1. Select project
  2. Project Overview
  3. Project Settings
  4. ADD FINGERPRINT - enter SHA1 to Certificate fingerprint
  5. Save
RonTLV
  • 2,376
  • 2
  • 24
  • 38
3

In case of anyone facing this issue after Aug 2020. New SHA1 can be found at Setup->App Signing on your play console. Everything else is the same as @PrinkalKumar as answered.

tsvillain
  • 61
  • 1
  • 3
3

in new version of the google console:

Setup > app integrity

3

All answers specify either an outdated version of the Play console, or don't specify how to do it in the Firebase console.

So here goes my answer :

  1. Get your SHA in your Google console by navigating to Release > Setup > App integrity in the menu, then clicking "App signing" tab. Copy the SHA-1.

enter image description here

  1. In your Firebase console, go to Project settings > General tab. At the very bottom of the page, click "Add fingerprint". Paste the previously copied SHA-1 and save.

enter image description here

enter image description here

Chris Neve
  • 2,164
  • 2
  • 20
  • 33
1

If you enabled "Google Play App Signing" when publishing your app, you are now probably dealing with two fingerprints:

The one coming from your local keystore (keytool -exportcert -keystore path-to-production-keystore -list -v), known as the "upload cert".

The new one generated by Google when you enabled Signing (the "signing certificate").

The conflict with this situation, is that you may end up with two OAuth 2.0 client IDs:

  • The one that you created before publishing your app (and before enabling google signing), which is indeed the "right" one.

  • A NEW one created by Google when you enabled Google Signing.

You can verify this fact from: Google Play Console -> Games Services -> Select your App -> Games Details -> API Console project -> Credentials -> OAuth 2.0 client IDs

SOLUTION

In order for Google Sign-in (and all related Games Services features) to work, I had to correct the fingerprint for my pre-existing OAuth2 Client ID (the one that I created before publishing my app).

  1. Look for the "right" OAuth 2.0 client ID: Google Play Console -> Games Services -> Select your App -> Linked Apps --> Select your App --> Take note of the "OAuth2 Client ID" at the bottom.

  2. Look for the "Signing" certificate: Google Play Console -> Games Services -> Select your App -> Game Details -> API Console project -> Credentials -> OAuth 2.0 client IDs --> "Android client for XXXXXX (auto created by Google Service)" --> Take note of the value (xx:xx:xx:etc....) Comment: In order to reuse this value in my other OAuth 2.0 client ID, I had to replace it with some dummy number. Otherwise, you will get error: "Certificate already used in some other project".

  3. Go to your pre-existing OAuth2 Client ID: Google Play Console -> Games Services -> Select your App -> Games Details -> API Console project -> Credentials -> OAuth 2.0 client IDs --> Select "OAuth 2.0 client ID" from step 1. Update certificate value with the one from step 2.

This solved my issue. Multiplayer is working perfectly in my app (Match4App).

Pablo Alfonso
  • 2,317
  • 1
  • 18
  • 24
1

Update SHA-1 Key in Firebase project setting

enter image description here

Also check your google cloud project api key setting and also add SHA-1 Key credentials if you have Key restrictions.

enter image description here

Tushar Rai
  • 2,371
  • 4
  • 28
  • 57
-1

just goto the google play console > liked account and link your firebase project. Now it works fine!