125

I'm trying to create a dynamic link in Firebase, when I'm selecting the android app, it shows an error saying "Add SHA-1 to this android app", I've already added a credential, but I'm not sure how exactly do I "add SHA-1 to the app"

How is this done?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
John Sardinha
  • 3,566
  • 6
  • 25
  • 55

20 Answers20

186

SHA-1 generation in android studio:

change firebase project setting

Press add fingerprint button


  1. Select Gradle in android studio from right panel

  2. Select Your App

  3. In Tasks -> android-> signingReport

Double click signingReport.

How to get sha1 fingerprint


You will find the SHA-1 fingerprint in the "Gradle Console"

Add this SHA-1 fingerprint in firebase console

Add SHA1 fingerprint

ABcDexter
  • 2,751
  • 4
  • 28
  • 40
Damini Mehra
  • 3,257
  • 3
  • 13
  • 24
  • 4
    remember in the output of signing report copy both the release and debug sha1. – humazed Mar 02 '18 at 00:55
  • Couldn't get SHA. – CopsOnRoad Mar 08 '18 at 18:05
  • 3
    well, it took me some time to find the "Select gradle" because the panel was in the right size. :)))) – dod_basim Mar 28 '18 at 21:45
  • 2
    Android Studio 3.3: Click on the elephant icon in the Gradle panel, select the project, type in the Command line: "signingReport", click OK – norbDEV Sep 25 '18 at 11:56
  • This totally worked, but Android Studio saw fit to switch my default configuration to creating a signing report instead of running the app. Just a heads up in case running the app breaks for you after finding this value. – rob5408 Dec 16 '19 at 14:19
  • Can't find: "Select Gradle in android studio from right panel" – Pete Alvin Jan 02 '20 at 03:51
  • The answer gives you the debug key, check this answer if you are using another key for production https://stackoverflow.com/questions/38297493/get-android-release-certificate-fingerprints – Shady Mohamed Sherif Mar 18 '20 at 09:34
  • 1
    For anyone searching the gradle option,A button "Gradle" is placed tilted vertically on the right side of the window. – Ajay Stefin Jun 23 '20 at 17:31
  • I didn't find debug sha1. I only see md5, sha1, sha256. – A Yashwanth Mar 28 '21 at 04:47
  • this works but is it the same sha1 that's used in production or its for debug purposes only?? – NMukama Jul 19 '21 at 03:51
177

If you are using Google Play App Signing you need to use the SHA1 from google play since Google will replace your release signing key with the one on googles server

enter image description here

humazed
  • 74,687
  • 32
  • 99
  • 138
  • 22
    This needs to be a lot higher. I totally missed that my key is just for uploading and then google resigns it on its own. Took me better part of a morning to realize this – somerandomusername Jul 04 '18 at 07:57
  • 3
    Really helpful! The Google App Signing SHA1 has to be added to the list of SHA1's on your services. – Lucy Jul 07 '18 at 14:11
  • 6
    Lifesaver! This should be highlighted in the [Google App Bundle documentation](https://support.google.com/googleplay/android-developer/answer/7384423). They mention it under **Tips and Best Practices** at the bottom of the page. However, it is unclear what is required and how to implement. – AdamHurwitz Oct 01 '18 at 11:05
  • Had to use upload key certificate's SHA-1 and SHA-256. Thanks btw. – mdhz Oct 31 '20 at 11:46
  • 1
    Would be helpful to mention _where you can find that_ in google play: On the left hand side in https://play.google.com/console go to ***Release > Setup > App Integrity*** then click the App Signing tab – Flion Jul 10 '23 at 04:12
55

Alternatively you can use command line to get your SHA-1 fingerprint:

for your debug certificate you should use:

keytool -list -v -keystore C:\Users\user\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

you should change "c:\Users\user" with the path to your windows user directory

if you want to get the production SHA-1 for your own certificate, replace "C:\Users\user\.android\debug.keystore" with your custom KeyStore path and use your KeystorePass and Keypass instead of android/android.

Than declare the SHA-1 fingerprints you get to your firebase console as Damini said

Dhruv Tyagi
  • 814
  • 1
  • 9
  • 28
gbaccetta
  • 4,449
  • 2
  • 20
  • 30
  • 1
    You need to CD to the java bin folder for keytool to work. For me it was, `C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin` although you might have a general java edition installed directly in `C:\Program Files\Java\...` – Kind Contributor Apr 22 '19 at 05:31
39

MacOS just paste in the Terminal:

keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android
norbDEV
  • 4,795
  • 2
  • 37
  • 28
35

for Updated Android Studio(12 May 2021)

  1. Click on Gradle right side
  2. Click on the elephant icon and type the command
gradle signingReport

press Enter

Now, you will see BUILD SUCCESSFUL in the Run window that you can open from bottom just scroll that window upward and you will find your SHA1 key there. Add this key to firebase

  1. In your Project settings, go to the Your apps card.
  2. Select the Firebase Android app to which you want to add a SHA fingerprint.
  3. Click Add fingerprint.
  4. Enter or paste the SHA fingerprint, then click Save.

At last, while running your App please check you change the run configuration to app else only the signingReport Task would be running again and again.

Shubham Garg
  • 971
  • 8
  • 18
14

If you are using Google Play App Signing, you don't need to add your SHA-1 keys manually, just login into Firebase go into "project settings"->"integration" and press a button to link Google Play with firebase, SHA-1 will be added automatically.

Torello
  • 936
  • 11
  • 15
  • As we know its totally fine to link Firebase and Google Play, this is a super easy way to get rid of the SHA generation and integration steps. Within a minute i was able to make my Live app's google sign in bug go away. Thanks. – mohit kejriwal Jun 14 '20 at 06:42
  • I am using phone number OTP firebase authentication in my app so i added my project in the firebase console and also added SHA-1 & SHA-256. Then i uploaded my project to Google Play Store and link it with my project in the firebase. Now, SHA-1 on the Google Play Store is different than the firebase one. Is it a problem ?? Thank you – ibrahim Feb 07 '23 at 07:57
  • If that sha was added during firebase integration with google play, that sha should be right. – Torello Feb 07 '23 at 12:31
9

Run this command from your android directory.

./gradlew signingReport 

If you're not in the android directory already, run this instead:

cd android && ./gradlew signingReport
iDecode
  • 22,623
  • 19
  • 99
  • 186
  • This is a good answer because the command displays the fingerprints for all of the app's Build Types and Flavors – Ícaro Aug 01 '23 at 20:08
8

Just In case: while using the command line to generate the SHA1 fingerprint, be careful while specifying the folder path. If your User Name or android folder path has a space, you should add two double quotes as below:

keytool -list -v -keystore "C:\Users\User Name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Gomez NL
  • 912
  • 9
  • 12
6

Try pasting this code in CMD:

keytool -list -v -alias androiddebugkey -keystore  %USERPROFILE%\.android\debug.keystore
Alexandre Tranchant
  • 4,426
  • 4
  • 43
  • 70
6

For linux Ubuntu Open Terminal and Write :-

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Mohammad Sommakia
  • 1,773
  • 3
  • 15
  • 48
Predator_Shek
  • 71
  • 1
  • 2
5

On Windows, open the Command Prompt program. You can do this by going to the Start menu

  keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

On Mac/Linux, open the Terminal and paste

   keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
4

linux os terminal run this :

  keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass androi
Dilshan Dilip
  • 707
  • 6
  • 9
3

when I generate sha1 key using android studio

Gradle -> Tasks -> android-> signingReport and double click

That sha1 key is worked in debug mode but not worked when i build singed APK

so I generated sha 1 key using cmd it work

  • go to java\jdk version\ bin folder

example

C:\>cd C:\Program Files\Java\jdk1.8.0_121\bin

and type

keytool -exportcert  -keystore {path of sign jks key } -list -v

example

keytool -exportcert  -keystore F:\testkey\damithk.jks -list -v
damith alahakoon
  • 270
  • 4
  • 14
1

Instead Of Writing Command, You can Follow the Following Steps For Copy SHA

  1. Open Android Studio
  2. Open Your Project
  3. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
  4. Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
  5. Click on Your Project (Your Project Name form List)
  6. Click on Tasks/Android
  7. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar).
iDecode
  • 22,623
  • 19
  • 99
  • 186
yash sanghavi
  • 368
  • 3
  • 5
0

Open a terminal and run the keytool utility provided with Java to get the SHA-1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

To get the release certificate fingerprint: keytool -exportcert -list -v \ -alias -keystore

0

Easiest and the best option, just open root directory in Command prompt and run "gradlew signingReport" this command.

Harjinder Bains
  • 356
  • 3
  • 7
0

To get the release certificate fingerprint, follow this easy detailed step.

Right click on your

android folder

add new file

name it 'key.properties'. (without the single quotation of course)

add this lines

storePassword=any unique password

keyPassword=re-enter unique password

keyAlias=upload

storeFile= we'll put this later on

On your terminal, add the following and Continue.

On Mac/Linux

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

On windows

keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

On password, enter the unique store password you put. On certificate information, just leave it blank and Continue. At the end, type yes to confirm your information and Continue.

Go to the specified path where your upload-keystore.jks file is put, copy the file or move it to your project. Specifically under this folder.

android/app

Go back to your key.properties file and specify where the upload-keystore.jks path is under storeFile. i.e.

../app/upload-keystore.jks

Go to

android/app/build.gradle

On the file, click

Open for Editing in Android Studio

New Window

On the new window terminal, add

./gradlew signingReport

and Continue.

Search for the results where both the variant and the config are

release

Under that, that's your release keys.

dev.bojack
  • 753
  • 5
  • 9
0

Run this command

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
Dr Mido
  • 2,414
  • 4
  • 32
  • 72
0

For debugging apk in android studio go to terminal and type:

cd app/build/outputs/apk/debug

then type:

keytool -printcert -jarfile app-debug.apk

You will get your SHA1 and SHA256 there.

Change path for release with debug.

Antoine
  • 1,393
  • 4
  • 20
  • 26
0

From your project directory for example:

E:\practice\firebase_auth_app>

Write:

cd android

And it must be like this example: E:\practice\firebase_auth_app\android>

and then write:

./gradlew signingReport
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 23 '23 at 15:33