85

In release mode, my google sign-in is not working, but it works fine in debug mode. I got a similar question from SO here, but I didn't get perfect solutions.

My handleSignInResult is coming false - How can this be fixed?

Elizabeth
  • 1,399
  • 1
  • 13
  • 25
  • 3
    Go to Google console >> Select the Project >> Select Credentials from left menu >>Select OAuth client for Android type >> You can see the SHA1 key written over there, that may be the development one >> Replace it with release SHA1 >> Save. That's it!! – Sunit Samanta Jan 17 '19 at 11:59
  • In my case problem was as: – Andrey Jan 28 '21 at 05:43
  • 1
    I have same problem but how to create release sha1 key? @SunitSamanta – Taki Rajani Feb 19 '23 at 07:27

16 Answers16

165

Yesterday same problem occurred to me.

Google has released a new signing service in playstore publish console in which google will signin your app with his keystore. After signing , it will give you a new SHA which you have to add in your firebase account.

Enter SHA provided by Google in your firebase account

Community
  • 1
  • 1
HarshitG
  • 2,677
  • 3
  • 16
  • 13
  • 5
    This is perfect solution. you have to add app SHA1 and Play store also. – Asesha George Jul 17 '17 at 06:58
  • 4
    I just copied all SHA-1 keys to the Firebase Console from the page above, downloaded the google-services.json, compiled and works fine. – Péter Aradi Nov 12 '17 at 22:12
  • @HarshitG pls check my issue at https://stackoverflow.com/questions/55235295/google-signin-working-in-release-apk-but-not-on-play-store – Shikhar Mar 19 '19 at 07:05
  • 4
    Which SH1 needs to be added in firebase App signing or Upload certificate? Is it needed to download the google-service.json file, build release app and upload updated app to playstore again? – Nabin Dhakal May 16 '19 at 09:53
  • 3
    @Nbn Add both SHA1 – HarshitG Aug 05 '19 at 07:20
  • 1
    Ughh you just saved me so much trouble; thank you... So there's a separate SHA for adding an app and one for playstore? Interesting. Thank you – Brian Mahecha Jun 05 '20 at 05:18
  • 1
    I wish I could vote this one up like a hundred times!!! Thank you! I now understand ... there is an upload certificate and google manages the signing certificate for the store. Gradle's signingReport task of course doesn't give you the latter. – kristof.taveirne Nov 19 '20 at 06:37
  • do we need to upload again after adding play store sha1 on firebase? – user3219477 Dec 07 '20 at 19:27
  • @Oush I will send you my address... :-P – HarshitG Jan 26 '21 at 17:37
  • @HarshitG have u experienced invalid google token issue after all this steps? – Richa Shah May 10 '21 at 07:31
  • It is strange how google has not made easy access to App Signing page. I had to google for the specific link and could not find normally from the play-store developer console. Also, i don't think their doc regarding google sign in mentions the above step. Very misleading i would have thought from google's side. – Yogesh Aug 23 '21 at 09:40
  • 6
    For anyone looking in 2021+, it's now on Play console -> setup -> App integrity – Graciela Carrillo Oct 16 '21 at 20:17
61

When you upload app on play store

After signing , it will give you a new SHA which you have to add in your firebase account.

enter image description here enter image description here Its Working HAPPY Coding Cheers

Add new SHA1 in https://console.firebase.google.com

Create Release SHA1 using Command Line

keytool -list -v -keystore "E:\Jsk_file\healthNickel" -alias healthNickel

keytool -list -v -keystore "E:\Jsk_file\YOUR_JKS_FILE_NAME" -alias YOUR_JKS_ALIAS_NAME

Enter keystore Password :- YOUR_KEYSTORE_PASSWORD

enter image description here

Keshav Gera
  • 10,807
  • 1
  • 75
  • 53
56

I had same problem, i did read some posts and was able to get work done by following below steps

Step 1) Please go to https://console.developers.google.com/apis/credentials?

Step 2) Click on create credentials ->select OAuth client ID ->select application type as Android

Step 3) then generate Signing-certificate fingerprint by writing below command in command prompt before that you should have keystore and its path

     keytool -exportcert -keystore "D:\PlayStore_keystore\myproject.jks" -list -v

Step 4) after click on enter you will be asked for

     Enter keystore password : 
     Enter password which you have used for creating keystore 

Step 5) then it will give details regarding keystore like SHA1,SHA256,MD5 etc.

Step 6) Enter SHA1 as fingerprint and give packagename which is in manifest file

step 7) Click create you will get new OAuth client ID

step 8) now you have got client id you will need to get google-services.json file.

step 9) please goto https://console.firebase.google.com

step 10) if you already have project with that packagename ->go to overview ->click on menu icon where packagne name is written

step 11) select settings goto-> project Settings-> add Android app (in the bottom) -> there will be option called Add fingerprint

step 12) in step 5 you have got SHA1 paste that in certificate fingerprint and save it

step 13) now download new google-services.json file (as it conatins new client id ,certificate_hash etc)

step 14) paste that google-services.json file in app folder in your android project.

step 15) You are good to go...

ofir_aghai
  • 3,017
  • 1
  • 37
  • 43
Janardhan R
  • 1,541
  • 12
  • 15
  • 1
    what i did was go to the dashboard console and activated app signing with google, then uploaded my certificate and it signed it but generated a new set of has code values that i then used in the firebase console. This worked for me. so your answer provided me a hint since i understood what was wrong – Akah Sep 06 '17 at 15:30
  • @xwaxes glad it helped – Janardhan R Aug 10 '20 at 08:01
31

Make sure you follow all the steps specified in the Guide

. If need be, create a new OAuth Client, new configuration file (the google-services.json) file and do everything step-by-step.

Also try adding a Web Client giving the same credentials. And for Android as well as Web client give both the SHA1 for debug as well as the release keystores. In Android Studio, at extreme left you will see a tab saying "Build Variants". Select the release mode there and do everything after that.

huskygrad
  • 1,257
  • 1
  • 10
  • 21
  • 1
    it worked...i created new OAuth Client where i used release apk SHA1 key. – Elizabeth May 04 '16 at 05:09
  • 1
    I have a doubt...if i want to edit my code like add new features i will convert it to debug mode..then what happen to my OAuth Client...which was made using release SHA1 key right??? – Elizabeth May 04 '16 at 05:11
  • You can add multiple SHA1 in the console. And If it worked earlier in debug mode, it should work again. – huskygrad May 04 '16 at 05:13
  • I keep coming back to this answer. I have to use the Web key instead of the Android key. – joe May 02 '17 at 01:23
  • 1
    @Sanket I could not understand your second para "Also try adding a Web...". Could you please elaborate – Shikhar Mar 19 '19 at 06:58
  • @ShikharJaiswal I meant the Type as Web Application. But please check the steps for the newer app signing service. – huskygrad Apr 19 '19 at 07:39
  • Thanks, i just copy the SHA-1 from google console and i paste it in the firebase project settings and then it worked!, thanks again – GSepetadelis May 20 '21 at 14:04
9

Go to Play store and Search for "App Integrity"

enter image description here

Google play store app integrity

Then Copy the SHA Keys and Add into the Firebase or Google Cloud signing keys.

and then you are good to go.

benimbolat
  • 143
  • 2
  • 8
7

Because you are asking about release version of Android so I assume you already have signed your application with keystore.

So in order to obtain the SHA1 of your release app.

  • Go to your /bin in JDK directory.

  • And run the following command in your cmd.

  keytool -list -v -keystore "key store path" -alias "key alias"

This command will give you all the required details of your release version. Copy the SHA1 string and add it to your firebase console.

You are good to go.

ankushlokhande
  • 870
  • 5
  • 20
Zankrut Parmar
  • 1,872
  • 1
  • 13
  • 28
  • 1
    https://stackoverflow.com/questions/6211919/errorkeytool-is-not-recognized-as-an-internal-or-external-command-operable-p If keytool is not recognized – user3156040 Oct 04 '19 at 01:33
  • 1
    thanks a ton man, I had my key.jks file I ran this command and got the sha1 and added to firebase console and that worked like charm – Mahesh Jamdade Dec 29 '19 at 04:58
  • also it is important to remember that when we release a new version to the playstore the new hash has to be added to the firebase console – Mahesh Jamdade Dec 29 '19 at 09:09
  • 1
    Thank you, worked! wasn't able to run my release build variant locally before releasing to make sure everything is working, but your answer helped! – Raed Ghazal Aug 27 '23 at 18:34
3

Whenever you are using any google api you must add your release hash key on the app you generated in google developer console if you have added hash key for debug.

Adeel Turk
  • 897
  • 8
  • 23
3

Ok I struggled with this and finally I found the solution here it is:

First of all there are three SHA1 keys

  1. Debug SHA1 key

  2. Release SHA1 key

  3. SHA1 key when you google play sign your app

Here you can get debug and release keys and for third key check HarshitG's answer. There is App signing certificate, this is that key.

Gather those three keys and add them in firebase console under SHA certificate fingerprints

Then Download the google-services.json file and add it in your YOUR_PROJECT_NAME/project/app/ [you'll see it if you change the view to Project from Android]

Rebuild, generate release apk and enjoy :)

Makarand
  • 983
  • 9
  • 27
  • That helped, thank you! Good thing is we need to add keys in Firebase console only, we don't need to add them to Google Cloud Console. In the Cloud Console, they are propagated automatically by and from Firebase. – Liker777 Jun 12 '21 at 02:43
1

For a Release (aka, Signed) APK: If you are only deploying to Firebase, you need to add the SHA1 for the same keystore file you used to sign the app.

After successfully adding the SHA1 into the Firebase Project console , get the latest google-services.json and update your project's module local copy.

I didn't see any docs on this so far (seems it's something you have to dig for); found it to be tricky stuff. Lot's of answers on SO. Found the Firebase deployment solt. thanks to:

  1. Answer in this thread to update SHA1 on Google Play, it gave me the idea maybe I need to fix something with SHA1: https://stackoverflow.com/a/44307293/2162226

  2. How to get the SHA1 for a signed APK: https://stackoverflow.com/a/34933381/2162226

ankushlokhande
  • 870
  • 5
  • 20
Gene Bo
  • 11,284
  • 8
  • 90
  • 137
1
  1. in the terminal go to the project folder->android-> paste this command and hit enter ./gradlew signingReport . this will generate set of keys for you .
  2. Then copy the SHA1 and SHA256 keys under release release label.
  3. add them in to your Firebase settings keys section.
  4. Download the googleServices.json and replace your existing googleServices.json with the new one and build the apk again.

hope this helped.

1

Best And fastest way to fix login social media by flutter application using firebase after upload the app in google play to solve problem go to google play console than setup > app integrity > from App signing key certificate copy sha1& sha256 and past in firebase account in android app add new sha1 and sha256 . for facebook error login also copy sha1 from App signing key certificate in google play console go to this website : http://tomeko.net/online_tools/hex_to_base64.php past in hex string and click covert than copy output base 64 and past inside app setting in facebook development

that's all

  • I would give you one million upvotes, but stack overflow won't let me. You saved me a mini heart attack on an app in production :D For Flutter, this is your quickest fix if signing in worked in debug mode, but not release mode. – DaReal Dec 05 '22 at 16:53
1

CAUTION

If exist you put more than one identifier for the same 'signingReport' (copy SHA1 and SHA256 from the same report object) this isn't work, keep this im mind.

This works for me:

  • Remove all SHA1 in firebase
  • Run ./gradlew signingReport in android folder and get SHA1 from debug mode.
  • Run this commmand with your data: keytool -list -v -keystore your_absolute_path_to_keystore -alias your_alias_from_keystore

(After that you will be promped to digit the password of key and it wil generate your SHA1 + SHA256 and other infos.)

  • Copy only SHA1 and paste it in firebase.
  • Download google-services.json again and move it to your android/app
Aroldo Goulart
  • 134
  • 1
  • 11
0

If you have two or more firebase projects or the google cloud project, there may be a duplicate SHA1. If such conditions have been explained in this link.

https://support.google.com/firebase/answer/6401008?authuser=0

Latief Anwar
  • 1,833
  • 17
  • 27
0

Before mindlessly running commands n stuff lets get some concepts straight!!


Your app needs to get signed by a signing certificate / keystore (that .jks file) to create a release build. Release builds are created in either Debug mode or Release mode (We'll learn about this futher on)

There are 3 types of these keystore files that you will come across:-

  1. Debug keystore generated by using ./gradlew signingReport
  2. Upload keystore generated by following these instructions
  3. Deployment keystore/Play Signing keystore which is automatically generated by Play Console when you first try to upload a app bundle there. (You can find it at Setup > App integrity > App signing). This keystore stays with Google. You do not have access to its .jks file. So its safe and wont get lost.

Now, I would say, if you wish to get your app on Play Store, DO NOT generate Debug keystore. Generate and ALWAYS use your Upload keystore only.

Why is this important?

  • Debug keystore are just able to sign your apps in Debug mode (not Release mode).

    Even if you try to use flutter build appbundle with --release flag, you are gonna get a app-release.aab which is signed in Debug mode! You can never publish an app signed in Debug mode in Play Store.

  • Upload keystore can sign your app in Release mode which can be published on Play Store.
  • Therefore, if you intend to publish your app in future, generate upload keystore by following these instructions and make changes to you gradle files accordingly. Do not generate that debug keystore cuz you wont need it.

This explanation should make you understand that why some answers are wrong which recommend to get a Debug keystore


Now the proper answer to the above question.

Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate

So if you are signing you app with upload keystore, add the SHA-1 fingerprint of your upload keystore in Firebase Console > Settings Icon > Project settings > Add fingerprintadd SHA-1 fingerprints

  • You can get the SHA-1 of Upload keystore using keytool -v -list -keystore /path/to/upload-keystore.jks

  • Also, you can get the SHA-1 of Upload keystore and Deployment keystore on Play Console at Setup > App integrity > App signing


Which SHA-1 should I add? There are two SHA-1 at Play Console.

You have to add both SHA-1 fingerprints to firebase.

Why?

  • For publish reviews you always have to submit your app signed with your Upload keystore. Play Console will accept your app update submission signed with that same Upload keystore only (So keep the Upload keystore safe). That's why, to make that Upload keystore signed App work properly you need to add SHA-1 of Upload keystore in Firebase.
  • After your publish review is Accepted, your app will be signed again using the Deployment keystore by Play Console (automatic), then it will be published on Play Store. So that's why to make that Deployment keystore signed App work properly you need to add SHA-1 of Deployment keystore in Firebase.
ashuvssut
  • 1,725
  • 9
  • 17
0

This answer for people who using Visual Studio Xamarin Forms.

After I upload my app on Google Play I thought it will work, but it didn't, I did every Sha1 ,APIs but still not working, after weeks of trying I just change one option in Visual Studio, Then Release version start working very well, then I Archive .abb file and sign it with release keystore upload it to Google Play and finally working.

This is the method, right click on your

YourApp.Android -> Properties -> Android Options -> Code shrinker and select None

Here is image for my options

enter image description here

husham1414
  • 41
  • 1
  • 8
0

I did face the similar kind of problem while creating an app using expo.

If you are able to sign in while you are running the project in expo but not in APK, then it's definitely the problem with the certificates. Make sure you have pasted all the sha1/sha256 in the Firebase console (as I used Firebase, I am writing this with respect to it).

If app is published

If you have published the app for internal purpose (as I had published it for internal purpose) in google play console, then paste the certificates provided in the play console. Google play console -> setup -> internal app sharing -> copy sha1/sha256 from the internal test certificates.

If you have published the app publicly then you can refer the above answers that will definitely help you.

Prajwal H N
  • 59
  • 1
  • 2