[android] ERROR:'keytool' is not recognized as an internal or external command, operable program or batch file

When i use the command

C:\>keytool -list -alias androiddebugkey 
            -keystore .android\debug.keystore 
            -storepass android -keypass android

I get this error:

'keytool' is not recognized as an internal or external command, operable program or batch file.

I'm not able to get the certificate fingerprint(MD5) on my computer.

i have ensured that the keystore file is present in the appropriate location.

Any help?

This question is related to android keytool

The answer is


This means, that your shell couldn't find the tool on your harddisk.

A)

  • Change the working directory to C:\Program Files\Java\jre6\bin\
  • Execute keytool -list -alias androiddebugkey keystore <full directory name make sure that you use enclosing in quotes> -storepass android -keypass android

B)

  • Add C:\Program Files\Java\jre6\bin\ to your PATH variable

In my case problem was in using PowerShell instead of CMD :)


The keytool command might not be in your path—it’s part of Java, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v and locate the path printed after ‘Java binary at:’. Then use that fully qualified path replacing java (at the end) with keytool. If your path includes space-separated names, such as Program Files, use platform-appropriate notation for the names. For example, on Mac/Linux use Program\ Files, and on Windows use "Program Files".


On windows 8, go to C:\Program Files\Java\jre7\bin and in the address bar, type "cmd" without the quotes. This will launch the terminal. Then type in string as describe here.


Easy, just find the location where keytool executable is, normally is in java/jre(Version)/bin forexample in my computer is in C:\Program Files\Java\jre7\bin. all you have to do is go to environment variables, click PATH to make it active, then click edit, then add complete path where your keytool is, for me i will add C:\Program Files\Java\jre7\bin this will allow you to execute keytool commands without going to the directory where keytool is installed.


So if you have the following structure now:

 C:\Program Files\Java\jre6\bin\
                                keytool.exe
                                debug.keystore

then execute:

C:\Program Files\Java\jre6\bin>keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android 

I know there are already several answers but none of them worked for me, so i am posting one that worked for me, may be helpful for someone.

First of all directory to keytool.exe must be on path

and if instead of directory being on path it is giving error then Try starting command line as a normal user instead of as a administrator or changing the directory to home directory


Just search on the following path : C:\ ? Program Files ? Java ? jre1.xxx ? bin
be sure this bin folder includes this keytool.exe

Then open the command prompt.

then type : (cd means change directory) cd C:\Program Files\Java\jre1.8.0_231\bin

Then type the command, and press enter


This worked for me !! :

Go to this path or where ever you have your keytool.exe file

C:\Program Files\Java\jre7\bin

Hold shift and right click -> then press Open command window here

terminal will pop up, paste this in:

keytool -list -v -keystore "C:\Users\"Your-User-Name(no quotes)"\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

gives you both MD5 and SHA1


keytool ships with Android Studio as part of the JRE needed to run Android Studio.

On Windows its: C:\Program Files\Android\Android Studio\jre\bin\keytool.exe

On Mac its: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool

Add it to your environment variables then run the keytool command again.


I suffered alot trying to find a solution to it and finally I found the solution by first setting the jre path to system variables by navigating to::

control panel > System and Security > System > Advanced system settings 

Under System variables click on new

Variable name: KEY_PATH
Variable value: C:\Program Files (x86)\Java\jre1.8.0_171\bin

Where Variable value should be the path to your JDK's bin folder.

Then open command prompt and Change directory to the same JDK's bin folder like this

C:\Program Files (x86)\Java\jre1.8.0_171\bin 

then copy and paste the code below in cmd

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

For windows 10 you need to path C:\Program Files\Java\jre1.8.0_161\bin

restart command and open


The Works for fine

Go to Path

C:\Program Files\Java\jre7\bin> keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Developer\.android\debug.keystore"

Then enter Ketsore Password and job done!!


A simple solution of error is that you first need to change the folder directory in command prompt. By default in command prompt or in terminal(Inside Android studio in the bottom)tab the path is set to C:\Users#Name of your PC that you selected\AndroidStudioProjects#app name\flutter_app> Change accordingly:- C:\Users#Name of your PC that you selected\AndroidStudioProjects#app name\flutter_app>cd\

type **cd** (#after flutter_app>), type only cd\ not comma's

then type cd Program Files\Java\jre1.8.0_251\bin (#remember to check the file name of jre properly)

now type keytool -list -v -keystore "%USERPROFILE%.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android (without anyspace type the command).

screenshot of the codes to run


Locate where your keytool.exe inside java installation folder

mine is C:\Program Files\Java\jre1.8.0_181\bin open cmd anywhere and run

SET PATH=%PATH%;C:\Program Files\Java\jre1.8.0_181\bin;

change the path to the path you located your keytool.exe


all you can do is to navigate to your jre destination in your computer via command line and then once you reach bin, you type the keytool command and it would work.

C:\Program Files (x86)\Java\jre7\bin>
C:\Program Files (x86)\Java\jre7\bin>keytool -list -v -keystore"%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android



Alias name: androiddebugkey
Creation date: 23 Feb, 2014
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 479d4fe7
Valid from: Sun Feb 23 06:19:02 IST 2014 until: Tue Feb 16 06:19:02 IST 2044
Certificate fingerprints:
MD5:  DB:6A:8E:48:22:5B:37:73:B1:91:EF:43:3F:26:F0:EC
SHA1: B4:6B:2E:5F:5A:30:C5:E4:E7:12:BB:F0:74:FC:2B:43:64:3A:FC:15
SHA256: CB:59:F3:20:7D:5B:87:99:6C:0D:32:79:79:CF:4E:8C:16:C2:37:81:7B:
B0:AF:D2:EC:3C:11:21:53:58:62:F6
Signature algorithm name: SHA256withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: FA 96 17 9E 94 73 C3 42   F0 4B 55 5B C7 5B EE BB  .....s.B.KU[.[..
0010: C3 E5 D3 61                                        ...a
]
]

My case is, it doesn't work wherever I call it, no matter I path the file or not, if I open it with powershell.

but it works if I open it with cmd.


  1. Go to My computer -> right click -> system properties -> environmental variables -> Path -> add you jdk/bin to this path

    C:\Program Files\Java\jdk1.8.0_211\bin
    

*if this not work then

  1. In cmd set the path by using the below command

    set PATH=C:\Program Files\Java\jdk1.8.0_211\bin
    

now the path is set now you can use the keytool


Make sure JAVA_HOME is set and the path in environment variables reflects the bin directory of JAVA_HOME. Basically, the PATH should be able to find the keytools.exe file in your jdk location.


  1. Open where your KEYTOOL.EXE in yourJAVA file such as e.g C:\Program Files\Java\bin\keytool.exe.

  2. HOLD SHIFT and Right Click on the BIN Folder where your keytool.exe is located and click open CMD or RUN Command from here.

  3. This opens cmd. then type in

keytool -exportcert -alias NAME OF YOUR KEYSTORE -keystore PATH OF KEYSTORE.jks" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64

  1. Password Prompt, enter android and BOOOOOOOM...You have your Key.

Found it.

GO TO:

my computer->rightClick->properties->Advanced system settings->environment variables->find path in system variables->dbl click-> paste the "C:\Program Files\Java\jdk1.6.0_16\bin"->OK

GO TO:

cmd -> keytool -list -alias androiddebugkey -keystore "C:\Users\meee\.android\debug.keystore" -storepass android -keypass android

This is due to path not set where keytool.exe present.

Open command prompt in windows machine, traverse where you would like to run keytool cmd and set path where keytool.exe present

Step 1 : Open cmd promt and run "cd C:\Program Files\Java\jdk1.8.0_131\jre\lib\security"

Step 2 : Run below cmd to set path using "set PATH=C:\Program Files\Java\jdk1.8.0_131\bin"

Step 3 : Run keytool cmd, now it will be able to recognize.


Give:

keytool -list -keystore ~/.android/debug.keystore

Also in your line there is a space in keystore. Please check it.


Open Command prompt type this..

"c:\Program Files(x86)\Java\jdk1.7.0\bin\keytool.exe" -list -v -alias androiddebugkey -keystore "C:\Users\EIS.android\debug.keystore" -storepass android -keypass android

Then Hit Enter MD5 and SHA1 key will get


Open "Environment Variables" (you can get to it from your start menu search in Win10) double check the path that the jdk is in, to make sure it exists. For me, it said "...jdk1.8/bin" But when I copied that into Windows Explorer or command prompt, it said that it didn't exist. I checked where it should have been, and it said "jdk1.8.0_77"

A simple rename of the setting in Android Studio and keytool was working!


if you want to run keytool from any location of terminal

example: C:>keytool

you need to add the system variables

for Windows:

1) create:
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_45

2) add to Path
%JAVA_HOME%\bin;