71

I'm trying to get the SHA1 fingerprint so I can get an Google API key. Im in the following directory:

/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin

Then I execute the command from the google site :

keytool -list -v -keystore mystore.keystore

But it gives this error:

keytool error: java.lang.Exception: Keystore file does not exist: mystore.keystore
java.lang.Exception: Keystore file does not exist: mystore.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)

I followed tutorials but I can't get it to work! Does anyone know what I am doing wrong?

BTW: I'm using a Macbook Pro with Xamarin Studio 5.5.2.

Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40
Bas
  • 4,423
  • 8
  • 36
  • 53
  • The problem could be you are just trying to run the command copying from somewhere and not knowing what is actually is ,,(that happened to me ;) as well ), Once you know where and what it looks for , probably you would get the answer. – eRaisedToX Mar 03 '17 at 07:12

27 Answers27

97

Linux & Mac command

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

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

For publication certificate just follow https://developer.android.com/studio/publish/app-signing.html

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Andrew
  • 36,676
  • 11
  • 141
  • 113
35

You said you are running the command from...

/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin

Is your keystore file in that directory as well? If not then you need to specify the path to the keystore file, e.g.

keytool -list -v -keystore ~/somefolder/mystore.keystore

The keystore used should be the one used to sign the app. For Xamarin debug builds this will be the debug keystore located at /Users/[USERNAME]/.local/share/Xamarin/Mono\ for\ Android/debug.keystore. The command on OSX for this would be...

keytool -list -v -keystore /Users/[USERNAME]/.local/share/Xamarin/Mono\ for\ Android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Or on Windows 7

keytool -list -v -keystore C:\Users\[USERNAME]\AppData\Local\Xamarin\Mono for Android\debug.keystore -alias androiddebugkey -storepass android -keypass android
Tom Bowers
  • 4,951
  • 3
  • 30
  • 43
  • 2
    I can't find my keystore, I'm not sure in what directory it is in. – Bas Nov 20 '14 at 11:30
  • 3
    The fingerprint you need for the Google API key needs to be generated from the keystore which is used to sign your app. For a Xamarin debug build, it uses its debug keystore. Your command for this would be `keytool -list -v -keystore /Users/[USERNAME]/.local/share/Xamarin/Mono\ for\ Android/debug.keystore -alias androiddebugkey -storepass android -keypass android`, where [USERNAME] is your mac user. – Tom Bowers Nov 20 '14 at 11:40
  • 1
    I had to include "quotes" around the path name. Otherwise it gets confused with the space in the path. – willem Dec 08 '14 at 10:00
  • Suppperrrr I tried 100 articles but was unable to locate. Thanx alot – DeshDeep Singh Jun 25 '17 at 22:08
19

I faced the same issue, but resolved via following command:

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

OS: Windows 7

Pratik Patel
  • 2,209
  • 3
  • 23
  • 30
13

I have windows 10, I went to the route

c:/Users/usuario/.android/

Inside directory, execute command:

keytool -exportcert -keystore debug.keystore -list -v

Must generate fingerprint:

SHA-1: 73:BE:1A:.......................
MDO: 73:BE:A1.........................
SHA-256: 3B:B8:98:...................
10

Please provide the complete path of debug.keystore. Example: C:/Users/myusername/.android/debug.keystore instead of ~/.android/debug.keystore

10

Linux or Mac or Windows, use complete path

Mac:

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

Linux (Ubuntu in my case):

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

Windows:

keytool -list -v -keystore C:\Users\username\.android\debug.keystore
-alias androiddebugkey -storepass android -keypass android

DO NOT FORGET TO REPLACE username BY YOURS⛑️ VERY IMPORTANT❗️

Hope it works for you!

M E S A B O
  • 783
  • 1
  • 11
  • 15
8

In my case the debug.keystore is generated after the first run of the app on Android Studio

TooCool
  • 10,598
  • 15
  • 60
  • 85
6

I found this guide from teamtreehouse forum. hope it'll help you.

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.

You should then be prompted with the password as normal which you can enter (The password is android) . After that, you’ll see the list of certificates printed to the screen.

Luan Si Ho
  • 1,438
  • 2
  • 13
  • 17
6

I had the same issue. My error was

keytool error: java.lang.Exception: Keystore file does not exist:/Users/[USER_NAME]/.android/debug.keystore java.lang.Exception: Keystore file does not exist: /Users/[USER_NAME]/.android/debug.keystore at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:910) at java.base/sun.security.tools.keytool.Main.run(Main.java:416) at java.base/sun.security.tools.keytool.Main.main(Main.java:409)

I checked my /Users/[USER_NAME]/.android/ directory and I couldn't find debug.keystore file there.

Reason:

I used VSCODE and I did run my application only for iOS through iOS Simulator.

Solution:

I opened Android Studio and run my application for android with Android Emulator.

Then I got debug.keystore file in my .android/ directory.

Then I tried command below again:

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

And it runs without any error.

I hope it helps you.

Martin JH
  • 101
  • 1
  • 4
6

I had the same error in Windows 10 as well. But sorted it and finally got SHA-1 Key.

I followed these steps

1.Open C drive and follow this path C:\Program Files\Java\jdk1.8.0_201\bin .

2.Inside bin folder open CMD and run command keytool -exportcert -list -v -alias androiddebugkey -keystore C:/Users/Username/.android/debug.keystore . (Replace Username with your username).

3.Enter password as android .

Kevin Jose
  • 856
  • 8
  • 22
3

If you are on Windows open command prompt and RUN AS ADMINISTRATOR then paste the line keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore. That should work, it worked for me

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
Ronny K
  • 39
  • 3
3

So I have found the solution.

On Windows, open cmd from start menu and write cd C:\Users\put_here_your_username\.android and then write keytool -list -v -keystore ".\debug.keystore" -alias androiddebugkey -storepass android -keypass android

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 01 '22 at 08:53
2

I lived same problem on Windows 10 and solved that problem with writing below command:

keytool -list -keystore debug.keystore

I think with some other commands java couldn't find debug.keystore file but interestingly with that command it works for me.

Hasan Basri
  • 848
  • 8
  • 16
2

I had the same Error am using ubuntu 18.04

Solution:

Open terminal and navigate to /home/{$user}/.android

Then run the command

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

You will be prompted to enter a keystore password enter android

Hope this helps.

Genes
  • 300
  • 1
  • 3
  • 16
2

Below command should work:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
sweak
  • 1,369
  • 2
  • 6
  • 21
1

last update for Mac & Ubuntu

keytool -exportcert -alias androiddebugkey -keystore  ~/.android/debug.keystore -list -v
Mostafa Anter
  • 3,445
  • 24
  • 26
  • 1
    not working, `keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.` – Olegdater Feb 21 '20 at 08:42
1

I faced the same problem, I found that I had .android folder inside another .android folder. Make sure to find the right path of debug.keystore file on your system

I used this command and it worked

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

Majali
  • 480
  • 7
  • 11
1
keytool -list -v -keystore C:\Users\%USERNAME%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

Try this to get resolve from the problem

Chris Maggiulli
  • 3,375
  • 26
  • 39
Vishwan_9
  • 11
  • 1
0

If you are on Windows open command prompt and then Run it as an administration then paste this: keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%.android\debug.keystore

use password : android

then you will get SHA-1 and SHA-256 this worked smoothly for me.

0
  1. Install keytool on your system Keytool is included as part of the Java runtime. So by installing Java, you'll also have keytool in your system.

    To install Java, visit the JAVA SE Downloads page. Then, select the JDK Download link.

  2. After that, add the keytool folder to your system %PATH% (on Windows). In order to run keytool from the command line, you need to add it to your system PATH. This step is required on Windows only.

  3. Finally, run this command in a terminal, and don't forget to change the user name to your own: keytool -list -v -keystore "c:\users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

user3738870
  • 1,415
  • 2
  • 12
  • 24
0

Open CMD and navigate to Java bin folder for example:

C:\Program Files\Java\jre1.8.0_341\bin

Once you stand here then paste this:

keytool -exportcert -list -v -alias androiddebugkey -keystore C:/Users/*YOUR_PC_USERNAME*/.android/debug.keystore

Do not forget to change to your own PC username marked with * YOUR_PC_USERNAME *

Montekar
  • 104
  • 4
0

Double check that you are putting the correct address in my case I had two typos and that fixed it.

I had c:User instead of C:\Users\

0

Find your debug.keystore file by searching (usually it is in .android) and then use this

keytool -list -v -alias androiddebugkey -keystore "C:\Users\u_name\ .android\debug.keystore"

  • Use your own full path name not copy paste from anywhere.

It solved mine and this or some else solution will solve yours too.

0

just put this given command in your package.json file and hit run yarn sha-keys

"sha-keys": "keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android",

Akram Syed
  • 11
  • 4
0

in my case, keystore file was not generated at C:\Users\YourUserNameHere\.android\debug.keystore.

so i used below command to generate one and after that was able to get certificate fingerprint SHA1 & SHA256

android is the password used in below command

keytool -genkey -v -keystore C:\Users\YourUserNameHere\.android\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
Prem G
  • 162
  • 3
  • 8
0

'keytool -alias androiddebugkey -keystore %USERPROFILE%/.android/debug.keystore -list -v -storepass android'

when writing this code

'keytool error: java.lang.Exception: Keystore file does not exist: %USERPROFILE%.android\debug.keystore'

You may get an error like .

It will ask you for the path to the 'debug.keystore' file.

enter image description here

Enter the path in the '%USERPROFILE%' field

as follows

keytool -list -v -keystore C:\Users\username\.android\debug.keystore 
-alias androiddebugkey -storepass android -keypass android

Hopefully it benefits your business

0
  1. for mac
  2. keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 (type on your terminal you fill all the things and say yes)
  3. keytool (type on your terminal)
  4. close the terminal
  5. keytool -list -v
    -alias androiddebugkey -keystore ~/.android/debug.keystore (type on your terminal if you are using latest java it automaticaly save on .android may path is similar to like this [Storing /Users//.android/)
  6. keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android (type on your terminal you can get sha1 key)