30

I'm trying to use the Google Maps API in one of my projects and in the directions to set up the API credentials it wants me to add my application's SHA-1 signing-certificate fingerprint to the API.

In the instructions, it says to use the following command to get the fingerprint:

keytool -list -v -keystore mystore.keystore

When I try to use it, both in the Android Studio terminal as well as cmd prompt in my application's directory I get the following error:

keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\Name\.keystore

Note, my application is in D:\Projects\Android\AppName.

How do I get my SHA-1 signing-certificate to use with the Google Maps API?

FlameDra
  • 1,239
  • 5
  • 20
  • 36

14 Answers14

44

The easiest way of find the SHA-1 of your Android application is as follows: (NOTE: can only be done in Android Studio)

1) Open your project

2) Click on the 'Gradle' tab in the right hand corner of the android studio window

3) If no content is being shown click on the "Refresh all Gradle projects" icon in the left corner of the Gradle window (the blue icon)

4) From the contents select the one that has your project name

5) Go to 'Tasks' -> 'android' -> 'signingReport'

6) It will open a console, click the 'Toggle tasks executions/text mode' icon in the left top corner of it

Now you will be able to see your SHA-1 information along with a bunch of other information about your project in the console

This link contains an image that highlights the above stated steps

After checking this make sure to change your configuration module to your current project. To do this follow the below steps:

1)Click on the'select Run/Debug configuration' drop-down

2) Select app

3)Click on the'select Run/Debug configuration' drop-down again and select edit configurations

4)Select the 'General' tab and change the 'Module' to 'app', also tick the 'activate tool window' checkbox

5) press 'ok'

now you can run your project like before by pressing on the run button.

This link contains an image that highlights the above stated steps

hope this helped.

Suleka_28
  • 2,219
  • 2
  • 17
  • 37
  • Thanks you a lot! You really save my time, I've tried and tried to get SHA1 through console and again and again I've got an error. Thanks! – Sveta Antrapovich Aug 17 '20 at 12:36
32

The debug keystore file isn't in your application's directory, it's in your .android directory. If you're using Windows, it's probably in C:\Users\yourname\.android (where instead of "yourname" use your own User directory).

Once you know where it is, you can run the keytool like this:

    keytool -list -v -keystore "C:\Users\yourname\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Rapunzel Van Winkle
  • 4,950
  • 6
  • 27
  • 46
  • 1
    Your answer helped me. I was trying `keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v` and when I used your guidleine I changed ~ with `C:\Users\yourname` and it worked – YoussefDir Oct 07 '20 at 15:14
  • Same here (YoussefDir). I wonder why though. The error it was spitting out appears to be going to the right folder. Anyways @Rapunzel, it worked. Thanks! – Tosh Jan 02 '21 at 04:23
19

To find SHA-1 of your application, you can find like: To click on right side of your android studio click on gradle and then click on task-> android-> signingreport you will find your application sha-1 on below console. enter image description here

and to generate signing keystroke file you have to generate signing buid apk, to genrate signing build apk click on Build->generate signing apk->creaenew then follow the provedure you will find your keystroke file on your desire location.thanks

singh.indolia
  • 1,177
  • 12
  • 24
9

Important: Keep in mind debug.keystore won't be generated if you haven't run any app in you android studio. Ie: debug.keystore is generated after the first run of the app on Android Studio.

But you can also generate Release/Debug Keystores for signing Android apps at the command line.

  1. A debug keystore which is used to sign an Android app during development needs a specific alias and password combination as dictated by Google. To create a debug keystore, use:
    $ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

  • Keystore name: "debug.keystore"
  • Keystore password: "android"
  • Key alias: "androiddebugkey"
  • Key password: "android"
  • CN: "CN=Android Debug,O=Android,C=US"

Then inorder to access the Key Fingerprints:

  1. Open C drive and follow this path C:\Program Files\Java\jdk1.8.0_201\bin
  2. Then with bin folder open cmd
  3. Now execute
$ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v 

For further clarification refer :

https://developer.android.com/studio/publish/app-signing#debugmode https://coderwall.com/p/r09hoq/android-generate-release-debug-keystores

7

I found this from teamtreehouse forum. It solve my problem. try to follow these steps.

1) Open Command Prompt by pressing Start+R and typing cmd.exe.

2) Using Windows Explorer, find where your JDK directory is located (Usually Program Files >> Java) and copy the path.

3) In Command Prompt, type cd followed by the directory of your JDK’s bin directory. e.g: cd C:\Program Files\Java\jdk1.8.0_25\bin is the command I use (Yours may vary).

4) Using Windows Explorer, find where your .android directory is located (Usually under Users >> [YOUR WINDOWS USERNAME]) and copy the path.

5) Now, use this command below:

keytool -exportcert -alias androiddebugkey -keystore[PATH_TO_.ANDROID_DIRECTORY] -list -v

Replacing [PATH_TO_.ANDROID_DIRECTORY] with the path you copied. Note that you should be running this command in terminal/command prompt in your JDK’s bin directory (You did this in Step 3).

Mine is C:\Program Files\Java\jdk1.8.0_121\bin>keytool -exportcert -alias androiddebugkey -keystore C:\Users\HoSiLuan\.android\debug.keystore -list -v

Remember to use C:\Users\HoSiLuan\.android\debug.keystore instead of ~/.android\debug.keystore. I still got the error when type this shorten way.

Then enter password, normally it's android . After that, you’ll see the list of certificates printed to the screen.

Luan Si Ho
  • 1,148
  • 2
  • 9
  • 15
5

Following will give you SHA1, SHA256, MD5 for default debug key. And it can be used for developing and debugging with google play services.

Linux & Mac command

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

Windows

keytool -exportcert -keystore C:\Users\<USERNAME>\.android\debug.keystore -list -v

Replace with your windows account name example:

keytool -exportcert -keystore C:\Users\Aakash\.android\debug.keystore -list -v
Aakash Solanki
  • 345
  • 1
  • 3
  • 11
  • 2
    +1 for the mac one it worked perfectly. So, before pasting right in the terminal you can edit -storepass or -keypass if you'd want – Iqra. Nov 28 '20 at 01:47
3

here is the command line instructions password is android

keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\rashi\.android\debug.keystore       

replace Keystore path to your .android folder path

Rashid Iqbal
  • 567
  • 7
  • 10
3

for windows:
1. open console where you android project located
2. run keytool, if tells you that command unknown go to 3, otherwise, go to 4
3. navigate to folder with Java JDK, like: cd 'C:\Program Files\Java\jdk1.8.0_211\bin\' or install JDK if not found
4. execute
.\keytool.exe -list -v -keystore PROJECT-FOLDER\android\app\debug.keystore -alias androiddebugkey -storepass android -keypass android

Alex S
  • 68
  • 5
1

put this line in a single format =>

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

don't do that half line of code in upper line and half code in lower line and one more important thing remove / after -v/ to make it -v -alias .... so on

Android
  • 1,358
  • 4
  • 10
  • 22
Paras Arora
  • 145
  • 8
1

Simplest Way:

Just go to your User directory in windows lets say:

C:/Users/your_profile/.android/debug.keystore

use this as the target location.

Pmpr
  • 14,501
  • 21
  • 73
  • 91
0

To get the SHA1 key in the command Provide the file path to the debug.keystore file in .android folder

Kaveri
  • 131
  • 1
  • 6
0

This link https://developers.google.com/games/services/console/enabling has information on keytool

  1. Mac default debug keystone filepath is ~/.android/debug.keystore
  2. When using keytool -list -keystore ~/.android/debug.keystore, it will prompt to input password whose default value is android.
Shark Deng
  • 632
  • 6
  • 14
0

for this devleoper error you have to, first of all, find the sha key1 not from your .android directory instead of local debug Keystore in your project which you can find using android studio easily by clicking on gradle right hand side gradle>yourproject>android>signin report and paste the key on firebase fingerprint certification then download google service.json and place it in your app directory then at last you have to clean your gradel by using this command ./gradlew clean (Note: this cleaning stuff should be done otherwise same error will be there ) then build your project this will 100% work

-1

If you firstly install android, don't create any project yet or debug.keystore file delete own you, then you create new android sample project. and try to run "signingReport"