713

I am trying to make a Map app in Android Studio, on Windows. How can I find the SHA-1 fingerprint certificate number?

When I was using Eclipse it was right under Windows -> Preferences -> Android -> Build. But in Android Studio I couldn't find a similar option.

I read in the documentation that

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

So I tried setting my Java bin path and running the following command, taken from here:

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

However, I got an error message saying that it is an illegal option.

Step by step, how do I get this information in Android Studio?

As a workaround: I previously registered my app using the SHA-1 fingerprint generated by Eclipse. Can I use the same API key to work on my project in Android Studio?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85
  • 2
    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:21
  • Try following this: [how-to-get-sha-1-key-in-android-studio?.](https://stackoverflow.com/a/51379022/7748753) – Himanshu itmca Jul 17 '18 at 10:27

52 Answers52

1493

Easiest ways ever:

Update added for Android Studio V 2.2 in last step

There are two ways to do this.

1. Faster way:

  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 (root))
  6. Click on Tasks
  7. Click on Android
  8. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))
  9. Select app module from module selection dropdown to run or debug your application

Check the screenshot below:

enter image description here

2. Work with Google Maps Activity:

  1. Open Android Studio
  2. Open Your Project
  3. Click on File menu -> Select New -> Click on Google -> Select Google Maps Activity
  4. A dialog would appear -> Click on Finish
  5. Android Studio would automatically generate an XML file named with google_maps_api.xml
  6. You would get debug SHA1 key here (at line number 10 of the XML file)

Check Screenshot below:

Enter image description here

Android Studio V 2.2 Update

There is an issue with Execution.

Solution:

  • Click on Toggle tasks execution/text mode from Run bar

Check Screenshot below:

enter image description here

Done.

micstr
  • 5,080
  • 8
  • 48
  • 76
Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
  • 8
    Great :) but can I use the this SHA1 (Produced as you described) in my Google Developer Console to create a Credentials for my application? Because it in (Signing Report) window it says (config: debug) not release mode? – Ashraf Alshahawy Jan 25 '16 at 13:35
  • @HirenPatel I have a signed key store, but I don't know how to create sha 1 for the generated key store using Android Studio, any tips. – Ashraf Alshahawy Jan 25 '16 at 14:36
  • @Astrount, can you please refer https://developers.google.com/maps/documentation/android-api/signup?hl=en one ? – Hiren Patel Jan 25 '16 at 14:51
  • 2
    For release SHA1 for keystore, please refer http://stackoverflow.com/questions/15727912/sha-1-fingerprint-of-keystore-certificate/33479550#33479550 one – Hiren Patel Mar 07 '16 at 10:08
  • Just one point to keep in mind that the running task 'signingReport' applies for each and every variant of your selected module. Configuring different keystores will result in different Fingerprint for every variant, though rarely possible but better to know. Make sure you copy fingerprint for the right one. – vijay_t Mar 16 '16 at 13:05
  • 1
    @Vlado For release you have to build signed apk first and define signingConfigs in build.gradle. After these steps try running signingReport task again it will print release SHA1 hash value also. – Jayakrishnan Jul 20 '16 at 08:48
  • @HirenPatel after done this i am unable to run it is always generating sha1 instead od installing tha app – kalyan pvs Aug 11 '16 at 11:26
  • @kalyan pvs, please select your app from top center of android studio. – Hiren Patel Aug 11 '16 at 11:40
  • @HirenPatel thats what i am doing..after clicking the run button it is generateting SHA1 everytime.. – kalyan pvs Aug 11 '16 at 11:42
  • https://www.dropbox.com/s/b1sazy92y7p9fao/Screenshot_2016-08-11-17-15-19.png?dl=0 , please change to app from signing report – Hiren Patel Aug 11 '16 at 11:48
  • 12
    As of Android Studio 2.2 it shows up in Gradle console not Run – adsamcik Sep 21 '16 at 07:02
  • not in android studio 2.2 it works fine in previous version – Arpit Patel Oct 03 '16 at 11:55
  • 1
    @ArpitPatel, I have edited my answer with update 1 tag for Android studio v 2.2, kindly check it. Hope this would work for you. – Hiren Patel Oct 04 '16 at 06:07
  • @HirenPatel please check my answer No need to Use local gradle distribution – Arpit Patel Oct 04 '16 at 06:26
  • @HirenPatel Your update 1 for Android Studio 2.2 is also working on 2.2.2 – AnV Nov 19 '16 at 12:08
  • 1
    REALY thanks for allllll This material! Please keep using images! Please Keep being clear in the explanation !! Never assum that people know this.. or that... we do not knowwwww! rsrs Thanks again! you save me... after a long way! – Camila Yamamoto Jan 25 '17 at 08:29
  • 1
    Note that you won't be able to run or debug your project after you do this, until you switch your build back to "app". See the last step of Dinesh Sunny's answer below for how to do this. – Tyler Apr 04 '17 at 15:05
  • @HirenPatel How to get the SHA-1 fingerprint certificate in Android Studio for debug mode for kotlin? – Govaadiyo Nov 21 '17 at 09:17
  • @TofaaniKaanudo, please follow given steps. No change for kotlin as well. – Hiren Patel Nov 23 '17 at 07:48
  • you are the best, my long time running debug sha key is changed somehow. – Warwicky Aug 13 '19 at 09:23
  • 1
    Latest versions of Android studio does not have REFRESH button – Trect Apr 02 '20 at 11:47
  • Android Studio 4.2.1 had already remove this feature any other option to generate it. – blackjack May 26 '21 at 08:41
  • When I do all these steps, it gives me an error "mmissing keystore" what do I do??? I am new to android programming so easiest language please...thank you – Esvin Joshua Feb 17 '22 at 08:17
  • Just see: https://stackoverflow.com/a/67866731/9944300 – Amin Soheyli Jul 04 '22 at 05:26
348

My problem is the same as I have also shifted my Google Maps project from Eclipse to Android Studio. I have solved my problem by following this:

Go to your Java bin directory via the command:

C:\Program Files\Java\jdk1.7.0_71\bin>

Now type in the below command in your command window (CMD.EXE):

keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

Example:

keytool -list -v -keystore c:\users\James\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

Or you can just write this in cmd if you don't know the username:

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

And you will get the SHA1.

Then I created a new key from https://code.google.com/apis/console because of my package name got changed and then use this key in my application. It works fine.

Make sure you are in BIN folder of jdkX.X.X_XX (my folder name is jdk1.7.0_71), or else if you don't know what folder name you have then find it by opening the Java folder, and you will see what the folder name is, but you must be in your BIN folder and then run this command. Today I have got my SHA1 value in a cmd command window by the above procedure.

SNAPSHOT:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jamil
  • 5,457
  • 4
  • 26
  • 29
  • 1
    keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android Instead of typing your own username –  Aug 01 '15 at 05:05
  • Yes but as "keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android " is already showed in many of the examples in stack overflow...i just want to give another example. – Jamil Aug 01 '15 at 21:34
  • 1
    I couldn't copy the SHA1 from the CMD so I moved the whole output of your given command to a file by adding: `> output.txt` behind your command. You can also add `| clip` behind the command. You will get the output of the command in your Windows Clipboard. I hope it also saves time for others. [More info about using | clip](http://www.labnol.org/software/copy-command-output-to-clipboard/2506/) – Sjoerd Pottuit Jan 05 '16 at 14:58
  • 1
    @SPottuit: Interesting tip for `clip.exe`, din't know it existed, thanks. Also, removing `-v` will give you the SHA1 only as output, or on Windows you can pipe the output from -v through `| find "SHA1" | clip` – Dan Dar3 Mar 22 '16 at 13:33
  • For macOS/Linux user the command is `keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android` – M.Ed Jul 09 '22 at 19:15
319

Many Users has given their answers and it's working fine in Android Studio's version below 4.2. But for Android Studio 4.2 and newer version ,follows these steps to generate SHA Key . Steps are given in these pictures.

Steps:-

1) Click on the gradle. Top right on the Android Studio. As you can see in this picture.

Step1

2) Now click on icon as seen in below picture. A new searchable windows/screen will open.

SHA2 Or For Newer Android Studio sha12

3) Now type,gradle signingreport and press Enter to start generating SHA KEY as seen in below picture.

sha3

4) Your SHA Key will generate as seen in this picture. Using these steps you can generate SHA KEY in Android Studio 4.2.

sha4

Note:- If you want to get SHA KEY for Flutter/ React native projects. Follow these steps:--

1)Open Android Folder

open android folder

2)Click on gradlew and Open it in Terminal

enter image description here

3)Type the command "./gradlew signingreport" and you will get the SHA KEY for different Varient and Config

enter image description here

Rahul Kushwaha
  • 5,473
  • 3
  • 26
  • 30
  • @RahulKushwaha can you help me to generate release key. – Shashi Shiva L Jul 22 '21 at 11:42
  • @ShashiShivaL try using keytool .take help from this https://www.youtube.com/watch?v=mf3WdNqR9T4 – Rahul Kushwaha Jul 22 '21 at 12:18
  • @rezarahmad This is not working for me. I clicked on the icon, searched for "signing" and nothing popped up. –  Dec 08 '21 at 07:11
  • @SagarBalyan have you searched "gradle signingreport" not signing only?Just searched it .It will generate. – Rahul Kushwaha Dec 08 '21 at 08:11
  • 1
    Thank god this works on Win11. – Dimitri Williams Jan 30 '22 at 17:15
  • 1
    Option is not available for AndroidStudio Dolphin now. – Abhinav Saxena Oct 07 '22 at 15:08
  • @AbhinavSaxena ok. I will check and update it. – Rahul Kushwaha Oct 10 '22 at 04:35
  • @AbhinavSaxena I just updated my Android Studio to dolphin . I install latest gradle file . I am able to see the gradle on the top right corner.Please check it once. – Rahul Kushwaha Oct 12 '22 at 12:30
  • 1
    Okay, plus when I issued the `gradle signingreport` (there is a specific command that you use with gradlew bat/sh) from the command line, it failed. And I cannot locate this script from the gradle scripts (where you are telling me to see). – Abhinav Saxena Oct 12 '22 at 13:51
  • @AbhinavSaxena No, just check at the top right corner on the android Studio(Dolphin) . You will see the icon. Click on that .Enter gradle signingreport and press Enter . You just get you SHA key other keys . I have no idea to run the scripts with command line. Follows above steps to get your desired result. – Rahul Kushwaha Oct 13 '22 at 13:24
  • 1
    @RahulKushwaha thanks a lot for the tip. Could you please tell how to revert back the default Gradle task that is being run by Android Studio when you press "Debug" button? For me after executing `gradle signinreport` when I press "Debug" button Android Studio keeps executing `gradle signinreport`. – vocasle Feb 10 '23 at 10:58
  • 1
    @vocasle sorry for late response . When you run this command , app is changed to gradle signing report. Kindly changed back to app in "Add Configuration/Edit Configuration " top left of running devices. – Rahul Kushwaha Feb 15 '23 at 08:10
186

For Mac, this worked perfectly:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
JoeNCA
  • 1,977
  • 1
  • 9
  • 4
116

I just found the case to get SHA-1 in Android Studio:

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

And you will see all you need to get google_maps_key.

Image

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Stanislav Bondar
  • 6,056
  • 2
  • 34
  • 46
  • 2
    I found the Sha1 but it screw me up the project, it said "Error:exception during working with external system:" and change all structure on my project.... Thanks!!! for nothing!!! i think there is no way to get back. – user3050757 Jun 24 '15 at 15:27
67

In Android Studio 4+ (not sure about version), if you click on Gradle on the right bar, it won't show you any option to generate signing report. It will show you this:enter image description here

Click on Task list not built... info and un-check the option Do not build gradle task list.. and save the settings.

enter image description here

Then click gradle sync button: enter image description here

Then you'll see the signingreport option: enter image description here

Update for Android Studio Flamingo:

Option name changed

The option namely Only include test tasks in the Gradle task list generated during Gradle Syncs that needs to be unchecked will look this:

enter image description here

greybeard
  • 2,249
  • 8
  • 30
  • 66
artenson.art98
  • 1,543
  • 15
  • 15
56

The best solution for generating an SHA-1 key for Android is from Android Studio.

Click on Gradle on the far right side:

Click on the refresh icon, and you will see the name of the app:

Click on Tasks -> Report -> Signing Report:

Find the SHA-1 key on the bottom part in the console:

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ismaran Duwadi
  • 1,529
  • 12
  • 10
49

for me the shortest way is to type ./gradlew signingReport in the terminal command line.

P.s : if you are in Windows use .\gradlew signingReport instead.

narcis dpr
  • 939
  • 2
  • 12
  • 32
  • You can even use the Terminal tab inside Android Studio which saves you from having to navigate to the correct folder for your project. – wildcat12 Feb 18 '21 at 23:21
  • exactly, that's what i meant by ' terminal command line'. – narcis dpr Feb 20 '21 at 04:14
  • 3
    For Android Studio v. 4 +, the Gradle tab thing doesn't show anything. This is what works. – who-aditya-nawandar Jun 07 '21 at 09:51
  • 2
    @whoadityanawandar You can re-enable the gradle tasks from the settings menu. Settings -> experimental -> uncheck "Do not build Gradle task list during Gradle sync". Then resync your Gradle and the tasks should appear. – Donny Rozendal Jul 07 '21 at 12:48
48

[Updated 2017]

Step 1: On Top Right side of Android Studio Click On Gradle option.

Android Studio Click On Gradle option

Step 2:

-- 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 signingReport (You will get SHA1 and MD5 in Gradle Console/Run Bar)

enter image description here

Step 3: Click on the Gradle Console option present bottom of Android Studio to see your SHA1 Key.

enter image description here

Step 4: Now you got the SHA key but you can't run your project.That is why Change your configuration to app mode. See image below.

enter image description here

Like this.

enter image description here

Step 5: Happy Coding!!

Dinesh Sunny
  • 4,663
  • 3
  • 30
  • 29
48

If you just want the SHA certificate values, run the following command from the android folder:

 gradlew signingReport

...that'll give you a quick and easy view of your fingerprint

Delmontee
  • 1,898
  • 2
  • 26
  • 44
33

I did this way:

Step 1: Go to this folder

On Mac: /Users/<username>/.android/

On Windows: C:\Documents and Settings\<username>\.android\

On Linux: ~/.android/

Step 2: Run this command line:

keytool -list -v -keystore debug.keystore -storepass android

You will see the SHA-1 key.

Karthikeyan
  • 196
  • 2
  • 10
Son Nguyen Thanh
  • 1,199
  • 15
  • 19
28

For Linux & Mac

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 
Vicky
  • 5,098
  • 2
  • 33
  • 31
  • @vicky Example please.. /home/desktop/././. , abc.jks, which password n all, do we need all these details?? – Prabs Nov 27 '15 at 11:45
  • @prabs, I cannot get you. can you explain bit more? – Vicky Dec 21 '15 at 05:16
  • @vicky do we need to edit the command before executing it.. If yes, then what details we should give. That's my query. – Prabs Dec 21 '15 at 05:23
  • 1
    @prabs, you no need to give any extra info for debug key, You just execute the above command in your linux terminal. – Vicky Jan 18 '16 at 06:37
25

in the terminal type this command

gradle signingReport

very important

press Ctrl + enter

⚠ not enter

Work with Mac And Windows

Hamdy Abd El Fattah
  • 1,405
  • 1
  • 16
  • 16
24

i am going with @Hiren Patel answer but slightly change in android studio 2.2 and later

enter image description here

Arpit Patel
  • 7,212
  • 5
  • 56
  • 67
19
  1. Click on Gradle Icon in Right Pane.
  2. Click on Root Project Name.
  3. Click Tasks
  4. Click Android
  5. Click signingReport
  6. in bottom pane where you see Run report
  7. Click "Toggle Tasks Execytions/text mode"
  8. you can see the sha-1

Android Studio SHA-1

Sadegh-khan
  • 2,535
  • 1
  • 20
  • 30
19

Above answers give me a command not found error The correct terminal command that works for me was

./gradlew signingReport
yveszenne
  • 666
  • 8
  • 18
16

I directly used the following command from my Mac using the terminal. I got SHA1 Finger. This is the command:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hanuman
  • 958
  • 13
  • 35
  • it will work for windows also cmd is : keytool -list -v -keystore %USERPROFILE%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android – Hanuman May 11 '17 at 18:15
14

Follow the simple following steps to get SHA-1, SHA-256 & MD5:

  1. Click on Gradle placed at top right side of IDE. Gradle option at top right side of android studio IDE.
  2. Click on Gradle icon. Image showing Gradle icon.
  3. A popup window will opened, write signingReport after Gradle word & press enter. Write signingReport inside popup.
  4. Signing report will be generate. Signing report.
Abdul Waheed
  • 562
  • 6
  • 14
  • 2
    As a Mac user, only this solution worked. Saved my day. Thanks! – Vincent Gigandet Jun 12 '22 at 20:01
  • Unable to find anything under the app which opens from the right side. – Arbaz.in Jan 25 '23 at 05:45
  • @Arbaz.in if gradle is not showing on right side then please "ctrl + shift + A" in windows or "cmd + shift + A" in mac. A top bar will appears then switch to "Action" & write "gradle". Click on it and do above process. – Abdul Waheed Jan 26 '23 at 06:08
13

Recently Android Studio and in its last update 2020.3.1 has removed signingReport from Gradle sidebar but you can still get these details in Android studio in Terminal, just write the following command:

Windows:

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

Linux & MacOS:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 
Jagar
  • 777
  • 9
  • 24
12

For Android Studio 4.2 or new

Goto the Gradle on the right side

enter image description here

Open it and then Click on Execute Gradle Task and this pan is open enter image description here

then you have to type signingreport and press enter this will execute the command and will provide the result.

For Older Version of Android Studio

You can follow all of the above steps on the older version to get your result.

Syed Rafaqat Hussain
  • 1,009
  • 1
  • 9
  • 33
11

If you are using Android Studio, you can get the SHA-1 and MD5 certificate fingerprint (debug, release... all Build Types!!) fast through Gradle Tasks:

signingReport

The SHA-1 and MD5 certificates are shown in Messages Logs.

Android Plugin (configured in the Gradle app) creates a debug mode for default.

com.android.application

File route to keystore:

HOME/.android/debug.keystore

I recommend to attach debug.keystore to build.gradle. To do this put a file, debug.keystore, in an app folder and then Add SigningConfigs in Gradle app:

apply plugin: 'com.android.application'

    android {
        ................
        signingConfigs {
            debug {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
            release {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
        ........
    }

Extra: If you want creates for release, put a file, release.keystore, in an app folder. (This example uses the same debug.keystore.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
SergioLucas
  • 1,094
  • 8
  • 16
  • 1
    I did what you said above but I don't get the release SHA1, for release it returns me: Variant: release Config: none – Ashraf Alshahawy Jan 25 '16 at 14:41
  • Menu AndroidStudio: build/generated signed apk and create new file. After change signingConfig>release on build.gradle (above) – SergioLucas Jan 29 '16 at 18:27
  • I Ran this command using gradel script though that was not available in the list, it worked and I received the android debug key. – Malay M May 27 '21 at 00:35
10

I found a very easy process to find you MD5, SHA-1 fingerprint using Android Studio.

  1. Run your project
  2. Go to Gradle Menu (Menu: View -> Tool Windows -> Gradle)
  3. Go to 'signingReport' in Gradle window. (Your project -> Tasks -> android -> signingReport)
  4. Run it. (Using double-click or Ctrl + Shift + F10)
  5. In Run window you will find all info.

It's work only for debug mode. In realease mode I can not see sha-1. Here result of gradlew signingReport

Variant: release
Config: none
----------
Variant: releaseUnitTest
Config: none
----------
Variant: debug
Config: debug
Store: path\Android\avd\.android\debug.keystore
Alias: AndroidDebugKey
MD5: xx:xx:xx:62:86:B7:9C:BC:FB:AD:C8:C6:64:69:xx:xx
SHA1: xx:xx:xx:xx:0F:B0:82:86:1D:14:0D:AF:67:99:58:1A:01:xx:xx:xx
Valid until: Friday, July 19, 2047
----------

So I must use keytool to get sha-1. Here official Firebase doc:

Get_sha-1_for_release

user8542613
  • 745
  • 2
  • 14
  • 25
Md Sufi Khan
  • 1,751
  • 1
  • 14
  • 19
10

goto this website and find for yourself https://developers.google.com/android/guides/client-auth

method1 : ./gradlew signingReport

method2 :

    (a) for mac/linux

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




     (b) for windows ==>
keytool -list -v \
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

password : android

UNREAL
  • 430
  • 5
  • 11
  • if you want to connect android studio with firebase , using sha;;1 , just goto tools->firebase-> and follow the given steps , they automatically add sha1 to firebase, automatically download and save google-json file, and you can also add dependecies from there – UNREAL May 15 '22 at 18:26
9

For getting SHA1 for a production keystore:

  1. Build --> Generate Signed APK...

  2. Create keystore with password and follow the steps

  3. Go to your Mac/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin and drag the bin folder to the terminal after cd command to point at it so you can use the keytool tool. So, in terminal write cd (drag bin here) then press enter.

  4. Then, copy and paste this in the terminal:

    keytool -exportcert -alias Your_keystore_AliasName -keystore /Users/Home/Development/AndroidStudioProjects/YoutubeApp/app/YoutubeApp_keystore.jks -list -v
    

    Erase my path and go where you stored your keystore and drag your keystone and drop it after -keystore in the command line so the path will get created.

    Also, erase Your_keystore_AliaseName to put your alias keystone name that you used when you created it.

  5. Press Enter and enter the password :)

  6. When you enter the password, the terminal won't show that it receives keyboard entries, but it actually does, so put the password and press Enter even if you don't see the password is typed out.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fullmoon
  • 8,030
  • 5
  • 43
  • 58
  • you got my `THANK SO MUCH` award for `When you enter the password, the terminal won't show that it receives keyboard entries, but it actually does`. – Farid Oct 23 '16 at 18:51
9

It's very very easy in Gnu/Linux - Mac - Windows

First: - copy this command

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

Second: Now copy and paste the command in the terminal the Android Studio enter image description here

Result!

enter image description here

Good Luck!!

David Hackro
  • 3,652
  • 6
  • 41
  • 61
9

Use the instructions from the API Manager using keytool:

Get the package name from your AndroidManifest.xml file. Then use the following command to get the fingerprint:

keytool -list -v -keystore mystore.keystore


Other option using the terminal of Android Studio, using windows type :

.\gradlew signingReport

Very important press Ctrl + enter (Dont use only enter)

The you will get the SHA1 in the output

----------
Variant: IrinaIoanaDebugAndroidTest
Config: debug
Store: C:\Users\jorgesys\.android\debug.keystore
Alias: AndroidDebugKey
MD5: 12:D6:14:D5:87:CE:12:CC:8D:50:5D:CB:0E:D7:0B:3E
SHA1: 12:48:1F:75:26:E6:E2:D7:25:85:80:70:97:79:0A:5F:78:F7:51:7B
SHA-256: 12:5B:15:87:5E:E4:12:ED:79:DF:5E:B6:4B:9D:1E:FE:90:8C:67:FC:65:A8:53:79:54:02:98:22:6B:33:1E:6F
Valid until: Wednesday, September 11, 2052
----------
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
7

Click on the Terminal icon on the bottom left corner Terminal

cd to the android folder and run

gradlew signingreport

Once this is done, it will print the SHA-1, MD5, and SHA-256 keys

Renju Ashokan
  • 428
  • 6
  • 18
6

If you have Android Studio then it is very very simple. Just create a MapActivity using Android Studio and after creating it go into google_maps_api.xml. In there there will be a link given in comments. If you paste it in your browser, it will ask a few details to be filled in and after that your API will be generated. There is no need of using keytool and all.

Screen shot:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rizwan Ahmed
  • 919
  • 13
  • 19
  • But this will only work for debugging. You have to manually determine the release key fingerprint. – Hyndrix May 11 '15 at 04:51
  • @Hyndrix how do you manually determine the release key fingerprint? – Micro Aug 17 '15 at 18:33
  • This is a totally unecessary step. No need to create a MapActivity just for this. You just need to look in your Gradle Projects > app > Tasks > android > signingReports, and see the result in the Gradle Console under SHA1. – Kebman Mar 19 '17 at 16:09
6

This worked in my case: Use %USERPROFILE% instead of giving path .keystore file stored in this path automatically C:Users/user name/.android:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
KCN
  • 472
  • 6
  • 19
6

For me I was not getting signing report option in my android studio so I found very easy way to get SHA-1.

in terminal(of Android studio) execute this line :

./gradlew signingReport

Rajesh Satvara
  • 3,842
  • 2
  • 30
  • 50
5

For Windows 10, from the Android Studio terminal:

keytool -exportcert -alias androiddebugkey -keystore %USER_PROFILE%"/.android/debug.keystore -list -v

Note: For the debug.keystore, the password is "android". The debug keystore is typically located at "%USER_PROFILE%"/.android/debug.keystore.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Javad Jafari
  • 710
  • 6
  • 11
5

Click the Gradle icon on the right panel, then click on the (root).

Tasks > android > signingReport

Then the Gradle script will execute, and you will see your keys.

Drenmi
  • 8,492
  • 4
  • 42
  • 51
Balman Rawat
  • 3,922
  • 1
  • 17
  • 10
5

Use simple command:

keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v

and you will get the SHA1 key.

Sangeeta
  • 961
  • 2
  • 13
  • 34
5

The easiest way is

  1. From left side click on project folder >> android then right-click on gradlew folder and select open in terminal

  2. paste it into terminal './gradlew signingReport'

    Good Luck

Omar
  • 456
  • 7
  • 7
4

I want to add one thing with the answer given by Softcoder. I have seen some people couldn't give their debug.keystore path correctly on the command line. They see that they are doing the exact process accepted above, but it is not working. At that point try to drag the debug.keystore and drop it on the command line. It will help if the accepted answer is not working for you. Do the full process without any hesitation. It was a nice answer.

Community
  • 1
  • 1
Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85
4

Simple, Call this methods in your Splash Screen: hash() and getCertificateSHA1Fingerprint(), and then then keys would be visible in log

private void hash() {


            PackageInfo info;
            try {

                info = getPackageManager().getPackageInfo(
                        this.getPackageName(), PackageManager.GET_SIGNATURES);

                for (android.content.pm.Signature signature : info.signatures) {
                    MessageDigest md;
                    md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    Log.e("sagar sha key", md.toString());
                    String something = new String(Base64.encode(md.digest(), 0));
                    Log.e("sagar Hash key", something);
                    System.out.println("Hash key" + something);
                }

            } catch (PackageManager.NameNotFoundException e1) {
                Log.e("name not found", e1.toString());
            } catch (NoSuchAlgorithmException e) {
                Log.e("no such an algorithm", e.toString());
            } catch (Exception e) {
                Log.e("exception", e.toString());
            }
        }

        private void getCertificateSHA1Fingerprint() {
            PackageManager pm = this.getPackageManager();
            String packageName = this.getPackageName();
            int flags = PackageManager.GET_SIGNATURES;
            PackageInfo packageInfo = null;
            try {
                packageInfo = pm.getPackageInfo(packageName, flags);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            Signature[] signatures = packageInfo.signatures;
            byte[] cert = signatures[0].toByteArray();
            InputStream input = new ByteArrayInputStream(cert);
            CertificateFactory cf = null;
            try {
                cf = CertificateFactory.getInstance("X509");
            } catch (CertificateException e) {
                e.printStackTrace();
            }
            X509Certificate c = null;
            try {
                c = (X509Certificate) cf.generateCertificate(input);
            } catch (CertificateException e) {
                e.printStackTrace();
            }
            String hexString = "";
            try {
                MessageDigest md = MessageDigest.getInstance("SHA1");
                byte[] publicKey = md.digest(c.getEncoded());
                Log.e("sagar SHA",byte2HexFormatted(publicKey));
            } catch (NoSuchAlgorithmException e1) {
                e1.printStackTrace();
            } catch (CertificateEncodingException e) {
                e.printStackTrace();
            }
        }

        public static String byte2HexFormatted(byte[] arr) {
            StringBuilder str = new StringBuilder(arr.length * 2);
            for (int i = 0; i < arr.length; i++) {
                String h = Integer.toHexString(arr[i]);
                int l = h.length();
                if (l == 1) h = "0" + h;
                if (l > 2) h = h.substring(l - 2, l);
                str.append(h.toUpperCase());
                if (i < (arr.length - 1)) str.append(':');
            }
            return str.toString();
        }

Thank You.

Sagar
  • 554
  • 5
  • 21
3

The path of the keystore is in double quotes. It is working fine.

keytool -list -v -keystore "C:\Users\App innovation\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Happy Singh
  • 376
  • 3
  • 8
3

You can open the terminal from the android studio and write this line:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
cigien
  • 57,834
  • 11
  • 73
  • 112
2
  • Go to File > Project Structure Select app or mobile whatever you gave the name from Modules

  • Choose Signing tab.

  • You can add certificate clicking on the + button.

Kabir
  • 1,419
  • 17
  • 33
2

You can use following command and change AJAY SUNDRIYAL with your system name.This is only for your debug.keystore.This will work for you.

C:\Program Files\Java\jdk1.8.0_91\bin>keytool -list -v -keystore "c:\users\AJAY SUNDRIYAL\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
SANJAY GUPTA
  • 1,564
  • 13
  • 21
2
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 
1

This worked for me:

keytool -exportcert -alias androiddebugkey -keystore

Put path-to-debug-or-production-keystore here like C:\users\youruser.android\debug.keystore -list -v

Make sure you already are in the Java\jdk*\bin directory in a command or terminal window.

Then use Android as the password.

Sometimes web resources could be misleading. These are the ones working:

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jenia
  • 19
  • 1
1

If you need SHA1 for Google Maps, you can just see your error log in LogCat.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anton Smirnov
  • 89
  • 1
  • 2
1

When creating a new "Google Maps Project", in Android Studio V 1.5.1, the last screen opens the google_maps_api.xml file and displays the screen with instructions as follows:

Resources:

TODO: Before you run your application, you need a Google Maps API key.

To get one, follow this link, follow the directions and press "Create" at the end:

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r= YOUR SHA-1 + YOUR PACKAGE NAME

You can also add your credentials to an existing key, using this line:
YOUR SHA-1:YOUR PACKAGE NAME

Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key

Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file.
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR GOOGLE MAPS KEY</string>

To get YOUR GOOGLE MAPS KEY just cut and paste the URL link given into your browser and follow the instructions above at the time of creating the new application. The SHA-1 and Package names are already in the link given so you do not need to know them. They will however be in your project in the resources>Values>google_maps_api.xml file which is completed when you follow the instructions on creating the project.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anthony
  • 21
  • 1
1

The easiest way to get the finger print is to switch from app to signed report by clicking the drop down and click build.

enter image description here

Then you will be able to see the sha1 fingerprint at the bottom pane where you see the debug report and stack trace. N.B remember to switch back to app when you want to run your app on a device or an emulator.

Community
  • 1
  • 1
The_Martian
  • 3,684
  • 5
  • 33
  • 61
1

First Step Go your C drive open Program File ->Open JAVA Folder ->Open Bin and DoubleClick on jarsigner.exe

Then Open Cmd

Go to C:\Program Files\Java\jdk1.8.0_191\bin Then Enter Then Go C:\Program Files\Java\jdk1.8.0_191\bin>keytool -list -keystore "F:\BTG UPDATE BUILD\Beyond_The_Game.jks"

Enter JUST Show Enter Kaystoer Password ***** enter your PAssword enter finally Your Release SHA key Getting you Thank YOU enter image description here

1

In Mac

keytool -list -v -keystore ~/Desktop/AppRelease/FolderName/app_key -alias userName -storepass pw -keypass pw 
Amal
  • 261
  • 4
  • 9
0

i was doing this way its working

keytool.exe -list -v -alias ALIAS_NAME -keystore "E:\MID_PATH\trackMeeKeyStore.jks" -storepass PASS -keypass PASS
Mahesh Pandit
  • 348
  • 3
  • 7
0

Follow the following step

gradle(on the right corner) > click on your project name > Tasks > android > double click on signingReport

Then you will get SHA1 and other information in 4:Run(it will appear automatically).

MD Jahid Hasan
  • 786
  • 1
  • 9
  • 19
0

Steps:

  1. File
  2. Settings
  3. Experimental
  4. Unchecked the 'Do not build gradle task list during gradle sync' Or Unchecked 'Only include test tasks in the Gradle task list generated during Gradle Sync' and click 'OK'
  5. Go to file
  6. Sync project with Gradle files
  7. You will see the option on Signing reports under: Gradle -> Tasks ->Android -> Signing Report.
  8. Check the image below

enter image description here

Rezaul Karim
  • 1,311
  • 1
  • 18
  • 26
0

Here is the full process to generate SHA-1 and MD5 key in latest - 2023 android studio.

enter image description here

enter image description here

enter image description here

enter image description here

Divyesh Kevadiya
  • 41
  • 1
  • 3
  • 9
0

I tried almost all the ways which were given by other developers, but it was not successful. I run :

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

Which is for Windows. But I got error message saying: 'keytool' is not recognized as an internal or external command, operable program or batch file. Then I download JDK (Java Development Kit) for running this command. I updated my path also. Here is the steps how you can do that:

  1. Open the System Properties window.

  2. Click on the Advanced tab.

  3. Click on the Environment Variables button.

  4. In the System variable section, scroll down and find the PATH variable.

  5. Click on the Edit button.

  6. In the Edit environment variable dialog box, add the path to the keytool executable to the Value field. The path is usually something like C:\Program Files\Java\jdk-20\bin.

  7. Click on the OK button to close the Edit environment variable dialog box.

  8. Click on the OK button to close the Environment Variables dialog box.

  9. Close the System Properties window. Then I run the same command:

    keytool -list -v
    -alias androiddebugkey -keystore %USERPROFILE%.android\debug.keystore This time I got another error message:

New Error Message

Finally I changed command to this :

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

This worked for me. SSH keys