47

How do I get my SHA1 Keys for debug and release using android studio on a mac? (These are required for Google API Keys)

Quick learner
  • 6,975
  • 2
  • 30
  • 44
andyc101
  • 2,013
  • 2
  • 12
  • 8
  • 2
    Possible duplicate of [How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?](http://stackoverflow.com/questions/12214467/how-to-obtain-signing-certificate-fingerprint-sha1-for-oauth-2-0-on-android) – ahoffner Jan 21 '16 at 21:21
  • Easiest way to Get SHA-1 For Release and Debug mode android studio gradle. [Check this](http://stackoverflow.com/questions/15727912/sha-1-fingerprint-of-keystore-certificate/35308827#35308827) – Naeem Ibrahim Nov 16 '16 at 06:26
  • As per new Google Play Console UI, https://stackoverflow.com/a/63878148/8663316 – Faizan Haidar Khan Sep 14 '20 at 04:42

6 Answers6

147

DEBUG:

  1. Click on the Gradle tab on the right hand side of the view.

  2. Go to the ROOT folder -> Tasks -> android -> signingReport

  3. Double click, this will build with the signingReport and post in your bottom view your SHA1.

RELEASE:

  1. In android studio. Build -> Generate Signed APK... and click Next

  2. Copy your key store path and key alias.

enter image description here

  1. Traverse to the "bin" folder of the jdk path present in Java.

  2. Open terminal and enter:

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

  3. Enter your key password and this will print out your release SHA1.

andyc101
  • 2,013
  • 2
  • 12
  • 8
  • hey can u tell me how to generate release key using Linux terminal ..it gives me an error – Manish Sep 29 '16 at 04:47
  • 2
    **Kindly have a look on this video How to create SHA1 for release** https://youtu.be/g75cZXjmuj8 – Dharmbir Singh Feb 14 '17 at 11:02
  • I am building Apk using Jenkins running on Ubuntu, which creates Signed APKs, so how to get this release SHA1 & build SHA1. – Ashish Karpe Feb 16 '18 at 12:29
  • time saver method +1. Thx a lot. – Tushar Lathiya Feb 26 '19 at 09:36
  • I'm using Android Studio 4.0 (20 May 2020). Under Build, there is no 'Generate Signed APK'. Instead, it shows "Flutter, Make Module, Run Generate Sources Grade Tasks, Make Module (again), Analyze APK, Deploy Module to App Engine, Rebuild Project" plus some greyed out options. Searching 'Help' for keystore or 'key store' yields nothing useful. Has Android Studio changed in 2020? – Mark Ebden Jul 07 '20 at 17:16
  • Open the android module using android studio and you will find the options mentioned in this answer. When we open flutter projects, these tasks are not available and it is correct behaviour. These tools only show up when there is an android based project opened in the IDE – prasadsunny1 Jul 22 '20 at 09:08
  • Life saviour <3 – Malay M Jan 03 '21 at 16:26
  • Use can you terminal inside Android Studio (or IntelliJ) instead of terminal – Enigmo96 Mar 18 '21 at 08:59
24

Here is the new easiest way to find release SHA-1 or other certificates:

I assume that you have already built signed APK and uploaded it to developer console. Open google play console. Go to "Version Management", go to "Application Signing" and see your certificates.

Note: First google will ask you to activate "Application Signing" for your application.

enter image description here

Eren
  • 1,745
  • 2
  • 21
  • 30
  • 1
    Thank you. This is what I needed to figure out what my SHA1 key was after it had been signed as an App Bundle. Firebase Auth needed the SHA1 fingerprint to have been registered and I couldn't find where to see it. – fahadayaz May 28 '19 at 22:53
  • @HimanshuTiwari As per google : This is the public certificate for the app signing key that Google Play uses to sign your app before distributing it to Android devices. The app signing key itself is inaccessible and kept on a secure Google server. Use the certificate below to register your app signing key with your API providers. This means that the app signing key available in the dashboard may change if google decides to re-sign it . But our own app signing will always remain the same . Did you consider this scenario ?? – ArpitA Oct 31 '19 at 15:17
  • Thank you! After hours of searching, found your answer, and it fixed my issues. Thank again – Hisham Mubarak Jun 14 '20 at 19:30
7

To obtain SHA1 for DEBUG as well as RELEASE you have to add the key details in the signingConfigs of your gradle file,

see the example here

Jayakrishnan
  • 3,637
  • 26
  • 25
2

As per new Google Play Console UI, the option is available at Setup >> App Signing enter image description here

2

Step 1 ) Add release details in gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "app.devdeeds.com.yourapplication"
        minSdkVersion 17
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
//Signing configurations for build variants "release"
    signingConfigs {
        release {
            storeFile file("F:/Development/myapp.jks")
            storePassword "231232das"
            keyAlias "myapp_rel"
            keyPassword "dasd333_das"
        }
    }
    buildTypes {
    //link above defined configuration to "release" build type
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
}

Step 2) open gradle menu from right menu bar and then app > android > signingReport

enter image description here

Step 3) Click on signingReport and see the magic

enter image description here

Quick learner
  • 6,975
  • 2
  • 30
  • 44
2

For those who wants to generate release-apk SHA-1, SHA-256 and MD5 through Android Studio, follow these steps:

  1. Goto Project Structure -> Default Config -> Signing Config and then add "RELEASE SHA1" using details provided during Generate-Signed-Apk. For e.g.,

enter image description here

  1. Now set your Signing Config to $signingConfigs.'RELEASE SHA1'

enter image description here

  1. Finally, change your build variant to release mode and run signingReport to generate Keys in release mode.

enter image description here

Hope that, this would definitely generate the release-apk KEYS in easiest way.

Mohd Asim
  • 306
  • 2
  • 5