How can I find and run the keytool
Solution 1
I found a solution by myself as below quote. It works fine.
"C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe" -exportcert -alias
> sociallisting -keystore "D:\keystore\SocialListing" |
> "C:\cygwin\bin\openssl.exe" sha1 -binary | "C:\cygwin\bin\openssl.exe"
> base64
Solution 2
Simply enter these into Windows command prompt.
cd C:\Program Files\Java\jdk1.7.0_09\bin
keytool -exportcert -alias androiddebugkey -keystore "C:\Users\userName\.android\debug.keystore" -list -v
The base password is android
You will be presented with the MD5
, SHA1
, and SHA256
keys; Choose the one you need.
Solution 3
To get android key hash code follow these steps (for facebook apps)
- Download the openssl for windows here
- now unzip to c drive
- open cmd prompt
- type
cd C:\Program Files\Java\jdk1.6.0_26\bin
- then type only
keytool -export -alias myAlias -keystore C:\Users\<your user name>\.android\myKeyStore | C:\openssl-0.9.8k_WIN32\bin\openssl sha1 -binary | C:\openssl-0.9.8k_WIN32\bin\openssl enc -a -e
- Done
To get Certificate fingerprint(MD5) code follow these steps
- go to - C:\Program Files\Java\jdk1.6.0_26\bin
- inside the bin folder run the
jarsigner.exe
file - open cmd prompt
- type
cd C:\Program Files\Java\jdk1.6.0_26\bin
- then again type on cmd
keytool -list -keystore "C:/Documents and Settings/<your user name>/.android/debug.keystore"
- it will ask for Keystore password now. The default is "
android
" type and enter - Done.
Solution 4
keytool is part of the JDK.
Try to prepend %{JAVA_HOME}\
to the exec statement or c:\{path to jdk}\bin
.
Solution 5
I found this on another post, which did not get many upvotes, but it was super helpful for me. So will add it here.
Android Studio will bring a keytool with it.
C:\Program Files\Android\Android Studio\jre\bin
You can see his post below by Richar Heap, with a helpful reference. I did see this before but forgot about it. https://stackoverflow.com/a/51524526/4446406
Related videos on Youtube
Nguyen Minh Binh
I have been developing many mobile applications for more than 8 years with love, passion and enthusiasm for each and all of my apps. Being a developer, to me, is not only a career, it is also an opportunity to challenge myself and acquire more knowledge with each new project. I recognize myself as a friendly, skilled and disciplined developer, and I can adapt well both individually and collaboratively. Outside of work, I love playing around with my two sons as seeing their innocent smiles gives me more energy and motivation to work harder.
Updated on October 24, 2021Comments
-
Nguyen Minh Binh over 2 years
I am reading an development guide of Facebook Developers at here
It says that I must use keytool to export the signature for my app such as:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
I do not know how to find the keytool in order to run it. I tried to open a Windows command prompt and paste the above command, but it did not work.
-
Elshan about 5 yearsif you are running Linux based system
/usr/local/java/bin# ./keytool
if you are running Windowsfind the JDK install path and check bin folder
-
ashraf alqaabera about 4 yearsi found this ansour you can use it to solve the prob stackoverflow.com/a/57390582/13405428
-
-
Nguyen Minh Binh about 13 yearsCould you tell me how to run below command? keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
-
Nguyen Minh Binh about 13 yearsYes, I did. and when I run above command, the CMD say: 'openssl' is not recognized as an internal or external command, operable program or batch file.
-
Matthew Willis about 13 yearsYou probably need to install the openssl package as well via cygwin's setup.
-
Nguyen Minh Binh about 13 yearsI installed openssl package already. The problem still occurs :(
-
Matthew Willis about 13 yearsCan you run openssl by itself? What options do you see when you type "open" and press tab?
-
Nguyen Minh Binh about 13 yearsI installed cygwin as well as openssl already. But I don't know how to run them. I just run windows command line (cmd) and type the command.
-
Matthew Willis about 13 yearsYou have to access the cygwin shell. Installing cygwin should've made a shortcut on your desktop for it.
-
ArtOfWarfare over 11 yearsThis worked for me up until the final step. After typing in "android" it spits out garbage... my guess is it isn't using the proper encoding? If I enter in something like "blah", it tells me the password was incorrect. So it knows I have the password correct when I type in "android"
-
ArtOfWarfare over 11 yearsI found the issue was I had left off the flags -list and -v
-
Broo over 10 yearsthis worked for me. For debug keys use the -alias androiddebugkey.
-
Jaime Montoya about 7 yearsI found it here: C:\Program Files\Java\jre1.8.0_111\bin\keytool.exe
-
Andrew Grow almost 6 yearsI use for the release version next line: 1) cd C:\Program Files\Java\jdk1.8.0_162\bin and next 2) keytool -list -v -keystore "C:\AndroidProjects\Project1\app\myapp.keystore"
-
SHAHM almost 6 yearsOr C:\Program Files\Android\Android Studio\jre\bin
-
Todd Hale about 5 yearsI put the cer file and truststore file in the same directory and used this command:
"%JAVA_HOME%\bin\keytool" -import -keystore truststore -file certificate.cer -alias my-alias
-
Pete Alvin over 4 yearsThanks @SHAHM: great for us folks that don't want to explicitly download Java AGAIN and be bugged every week to upgrade to latest version.
-
Gustaf Liljegren over 4 years
keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.
-
dantechguy about 3 yearsI found that only
keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
worked for me. Found here from Google :) -
Gwi7d31 almost 3 yearsFor the "found it here" @JaimeMontoya comment as an addition. Add the directory for keytool.exe to your PATH. It'll make your life a whole lot easier.