48

I want to use assetlinks.json for appindexing. I am supposed to use a SHA256 fingerprint, but when I print out the signingReport in Android Studio, I only have SHA1.

Can I use SHA1? If not, how can I get a SHA256 signed app?

Using Manish Jain's answer, I have managed to list only the debug keys. If I put my actual keystore path and jks file in the path:

keytool -list -v -keystore "C:\Users\myself\Keystores\android.jks" -alias mykey -storepass 1password -keypass 2password

A different set of keys come up, which I assume would be the release key set.

The BIG QUESTION is why Android Studio only lists the debug keys when I print out the signingReport from Gradle and why it says Variant: releaseUnitTest, Config: none? Any idea?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Immy
  • 631
  • 1
  • 5
  • 15

11 Answers11

91

You can get SHA256 by using keytool using command prompt (windows).

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

For Mac users:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

If you have any special characters in your password, you may need to wrap the password in single quotes.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Manish Jain
  • 2,139
  • 19
  • 15
  • 1
    This solution worked, however, I just noticed that it listed only the debug keys. – Immy Feb 17 '17 at 07:42
  • 2
    keytool -list -v -keystore "path to release key store" -alias your release alias here -storepass android -keypass android From this I got both sha1 and sha256 – Neri Jun 07 '17 at 15:51
  • 1
    For *Macintosh* (the **password** is **empty** for debug) `keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore` – Bernard Agbemadon May 11 '21 at 21:25
49

There is a much simpler and updated method to find it, comes from this answer.

  1. Navigate to the Gradle tab at the right side of Android Studio.
  2. In the list, navigate to the app section and expand it.
  3. In the expanded list, navigate to the Tasks section and expand it.
  4. Again, in the expanded list, navigate to the android section and expand it.
  5. Double-click on signingReport, and find the SHA-256 Fingerprint at the Run box.

You will find your SHA-256 Fingerprint there.

As @quent commented, change your run configuration in the main toolbar to run the debug configuration again.

MJV
  • 652
  • 5
  • 14
  • 3
    However, don't forget to change run configuration in the main toolbar to be able to run debug configuration again. – quent Mar 14 '20 at 22:21
  • 7
    If you cannot find the section here mentions, there's an alternative execution: clicks the elephant button `Execute Gradle Task` on the upper left of gradle tab, and then type in `gradle signingReport`. (Or more on-sightly, the `Run Anything` button on the upper right of Android Studio, then type in the same command above.) – Samuel T. Chou Oct 19 '21 at 08:16
  • 1
    Step 3: It shows "Task list not built..." – Elmar Sep 06 '22 at 00:27
35

Go to the root directory of the project from the terminal and run the below command

./gradlew signingReport

You will get SHA-1, SHA-256, and other details

Naga
  • 1,931
  • 4
  • 25
  • 42
20

You can get it from the Google Play Console (https://play.google.com/apps/publish). Follow these steps:

  1. Go to your project in GPC.
  2. Expand "Release Management".
  3. Go to "App signing".
  4. Navigate to "App signing certificate".
  5. Copy SHA-256 fingerprint.
TylerH
  • 20,799
  • 66
  • 75
  • 101
Tincho825
  • 829
  • 1
  • 13
  • 15
  • I can found nothing like this in the newest GPC no in 2021 :-( – djdance Sep 15 '21 at 06:54
  • use Play console Search feature to search "Play App Signing", there you find all the public App signing key certificate/fingerprints listed :) – Pratap Singh Jan 03 '22 at 11:15
  • This answer is obsolete now; the new solution in Google Play Studios can be found in [this other answer](https://stackoverflow.com/a/73296202/2756409) to this question. – TylerH Aug 09 '22 at 18:05
10

Navigate to the Gradle tab at the right side of Android Studio

  1. Navigate to the Gradle tab on the right side of Android Studio
  2. Expand the project name
  3. Expand Tasks
  4. Expand Android
  5. Double click on signingReport
Vikram Kodag
  • 485
  • 5
  • 6
10

I always find using ./gradlew signingReport effective and good for me.

Just run the command in your project terminal.

Stephen Hechio
  • 160
  • 2
  • 7
5

As of 2021, in the latest Android Studio:

  1. Navigate to the Gradle tab on the right side of Android Studio.
  2. In the list, navigate to the app section and expand it. If you see the Tasks section in the expanded list, then follow this answer and you are good to go.

If you are not able to see the Tasks section then the alternate is:

Click the elephant button Execute Gradle Task on the upper left of the gradle tab, and then type in:

gradle signingReport

and it will print the SHAs in the console.

Safeer
  • 1,407
  • 1
  • 25
  • 29
4

Go to play console->App integrity

App signing

go to play console dashboard->App integrity ->app signing you will see SHA-1, SHA256 and MD5 keys

1

The tried solution: Upgrade your Gradle version

distributionUrl = https \: //services.gradle.org/distributions/gradle-5.4.1-bin.zip in gradle-wrapper.preperties

after that

  • Navigate to the Gradle tab on the right side of Android Studio

  • Expand the project name

  • Expand Tasks

  • Expand Android

  • Double click on signingReport

TylerH
  • 20,799
  • 66
  • 75
  • 101
kksal55
  • 500
  • 7
  • 14
0

If you need it automated, you can extract the value from signingReport gradle task output like this:

function signing_certificate_digest() {
  ./gradlew app:signingReport | \
    awk "/^Variant: $1\$/,/SHA-256|---/" | \
    grep 'SHA-256' | \
    cut -d' ' -f2
}

Which you can use like this in command line:

signing_certificate_digest debug

Also note:

When using Play App Signing, the signature of the binary signed by the upload key certificate will be different than the binary distributed by Google Play.

So this may not be suitable in that case.

arekolek
  • 9,128
  • 3
  • 58
  • 79
0

Migrating OP's solution from the question to an answer:

For Release:

  1. Go to: C:\Program Files\Java\jdk1.7.0_25\bin (or wherever your jdk file is).
  2. Type cmd in address bar in win explorer.
  3. Add: keytool -list -v -keystore "C:\Users\yourUserName\Keystores\android.jks" -alias yourAppName -storepass yourPasswordToKeystore -keypass yourPasswordToRequiredAppKey

Be careful!!!

If you have multiple keys in the keystore, it might not give you the correct matching one to the given app!

Another way of getting the SHA256 for your app:

Either on the Developer Console or Firebase, you can find the related SHA256 key somewhere. I couldn't find it now, but if you keep looking, it is there somewhere.

I just found it on the Google Play Developer Console:

  • Upload the first version of your app (if you haven't done it yet)
  • Go to App Releases in Release Management
  • Click Manage Beta
  • At the APK version click the "i" info button on the right

It will show you the SHA keys

TylerH
  • 20,799
  • 66
  • 75
  • 101