63

I want to get the SHA1 key from Android Studio on a Mac. From Eclipse it's simple, but I can't get this in Android Studio.

I have checked similar questions but didn't get any way to get that in MAC.

The SHA1 is different for signed and unsigned APK. Please mention the methods to get for both.

Thanks in advance.

mins
  • 4,503
  • 9
  • 45
  • 62
arslan haktic
  • 3,470
  • 4
  • 20
  • 35
  • 1
    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:25

10 Answers10

155

I got my Answer, it was quit simple. Open Terminal, Type command:

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

Press Enter: You will get the following info, and SHA1 can be seen there.

.....

Certificate fingerprints:

 MD5:  79:F5:59:................FE:09:D1:EC

 SHA1: 33:57:0A:C9:..................:91:47:14:CD

 SHA256: 39:AA:23:88:D6:...................33:DF:61:24:CB:17:47:EA:39:94:99

.......

arslan haktic
  • 3,470
  • 4
  • 20
  • 35
47

Very easy and simply finding the SHA1 key for certificate in only android studio.
You can use below steps:

A.Open Android Studio
B.Open Your Project
C.Click on Gradle (From Right Side Panel, you will see Gradle Bar)
D.Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
E.Click on Your Project (Your Project Name form List (root))
F.Click on Tasks
G.Click on android
H.Double Click on signingReport (You will get SHA1 and MD5 in Run Bar)

OR

1.Click on your package and choose New -> Google -> Google Maps Activity
2.Android Studio redirect you to google_maps_api.xml

enter image description here

Jignesh Goyani
  • 960
  • 7
  • 17
28

All above answers are correct.

But,Easiest and Faster way is below:

  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 Name like MyProject(root)

  6. Click on Tasks

  7. Click on android

  8. Double Click on signingReport

  9. Wait for few seconds and you will get SHA1 and MD5 in Console Bar

enter image description here

If you are adding a MapActivity in your project than see this answer for SHA1. How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?

Community
  • 1
  • 1
Poras Bhardwaj
  • 843
  • 1
  • 12
  • 33
9

Follow the below steps to get SHA1 fingerprint Certificate in Android Studio in 2.2v.

Open Android Studio Open your Project Click on Gradle (From Right Side Panel, you will see Gradle Bar)

Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)

Click on Your Project (Your Project Name form List (root))

Click on Tasks

Click on Android

Double Click on signing-report (You will get SHA1 and MD5 in Run Bar) Then click this button: enter image description here (top left of the error log) and you will get your SHA1 key.

Community
  • 1
  • 1
Sneha Patel
  • 383
  • 5
  • 6
6

The other way to get the SHA1 fingerprint instead of inputting a keytool command is to create dummy project and select the Google Map Activity in the Add an activity module and after the project is created you then open the values->google_maps_api.xml in that xml you'll see the SHA1 fingerprint of your android studio.

Rod_Algonquin
  • 25,268
  • 6
  • 47
  • 61
5

Use following command in the terminal:

keytool -list -v -keystore keystorename.keystore -alias aliasname
sebastian
  • 2,272
  • 2
  • 15
  • 25
  • 2
    Sorry But this didn't work its giving this error. keytool -list -v -keystore keystorename.keystore -alias aliasname keytool error: java.lang.Exception: Keystore file does not exist: keystorename.keystore java.lang.Exception: Keystore file does not exist: keystorename.keystore at sun.security.tools.keytool.Main.doCommands(Main.java:742) at sun.security.tools.keytool.Main.run(Main.java:340) at sun.security.tools.keytool.Main.main(Main.java:333) – arslan haktic May 06 '15 at 08:57
  • 2
    Of course you have to change "kestorename.keystore" to the actualname of your keystore file. Same applies for the aliasname. – sebastian May 06 '15 at 10:05
  • 3
    I got it, thanks, but what should be location of keystore file in my hard drive .. ? – arslan haktic May 06 '15 at 11:19
3

There is no way in Android Studio like Eclipse Windows -> Preferences -> Android -> Build.

Android Studio signs your app in debug mode automatically when you run or debug your project from the IDE.

You may get using the following Command!!

keytool -list -v -keystore  ~/.android/debug.keystore
iEngineer
  • 1,301
  • 1
  • 11
  • 27
Abdul Rahman
  • 965
  • 2
  • 8
  • 18
1

This helped!!

Type this is the Terminal keytool -list -v -keystore ~/.android/debug.keystore

It will ask you to enter the password enter 'android'

then you would get the details like the SHA1.

This worked for me.

0

After clicking signingReport You will get SHA-1 finger certificate for your application

After clicking signingReport You will get SHA-1 finger certificate for your application

I am here if you need any other help

Uzair
  • 159
  • 1
  • 7
0

FOR PRODUCTION BUILD / LIVE BUILD sha key follow these steps

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