‘keytool’ is not recognized as an internal or external command

'keytool' is not recognized as an internal or external command Техника

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

aprasadh opened this issue

Aug 13, 2018

· 27 comments

Keytool is a free command line tool that is added to your system when you install Java.

If you want to build an Android APK binary that can be distributed on the Play Store, you need to use keytool to generate the SHA-1 fingerprint for your signing certificate.

This is a required step when configuring the Firebase SDK for your Android (or Flutter) app.

This page on the official documentation explains how to use keytool, but not how to install it.

So if you got stuck with this before, this article explains all the required steps.

Code with Andrea is free for everyone. Help me keep it that way by checking out this sponsor:

Add subscriptions to your Flutter apps

Add subscriptions to your Flutter apps. RevenueCat gives you everything you need to build, analyze, and grow IAPs with just a few lines of code.

Ready? let’s go!

Getting the SHA-1 certificate fingerprint with keytool

This is how to use keytool to get the debug SHA-1 certificate fingerprint on Windows:

And this is the equivalent on macOS/Linux:

However, the commands above will only work if you have keytool already installed on your system, and it is included in your system PATH.

Дополнительно:  Как скачать и установить root права

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

If this is not the case, you’ll be greeted with this message (on Windows):

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

Let’s fix this.

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.

This takes you to a page called «Java SE Development Kit 15 Downloads».

Scroll to the bottom, and you’ll find download links for Linux, macOS and Windows.

Java SE Download links
Java SE Download links

Congratulations, the Java SDK is now installed on your system.

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, as keytool will is automatically installed on /usr/bin on macOS/Linux.

On the search box, type path, then open Edit the system environment variables (Control panel):

'keytool' is not recognized as an internal or external command

This opens the Advanced tab of the System Properties dialog:

'keytool' is not recognized as an internal or external command
'keytool' is not recognized as an internal or external command
'keytool' is not recognized as an internal or external command

Then press OK and close all the dialogs, then open a new command prompt.

Try running keytool. This time you should get this output:

This confirms that keytool is installed and configured in your PATH.

Using keytool to generate te SHA-1

You’re now ready to generate your SHA-1:

If you don’t have a keystore, you’ll need to generate one with Android Studio. This document about app signing on Android includes the information you need.

Дополнительно:  BlueScreen Screen Saver - скачать бесплатно BlueScreen Screen Saver 3.2

Conclusion

Phew! Getting keytool running on Windows requires a few steps, but we got there in the end.

Executable not found in path

aprasadh opened this issue

Aug 13, 2018

· 27 comments

Comments

@aprasadh

@ajsb85

The local CA is now installed in the system trust store! ⚡️
Note: Firefox support is not available on your platform. ℹ️
ERROR: failed to execute "keytool -list": exec: "": executable file not found in %PATH%


@daniellockard

That means you don’t have java’s keytool installed. Might want to install it.

@aprasadh

I ran keytool -list and I got this

@nickkaczmarek

@nickkaczmarek

@cretz

It’s going to happen on all Windows OS’s, because it looks for bin/keytool instead of bin/keytool.exe (Windows support was just merged after that). So someone needs to Windows-ify it, change the checkJava to stop assuming the keytool is there, and change the cert path lookup to respect JREs instead of just JDKs.

@nickkaczmarek

I saw that jre path also and thought it looked fishy. I ended up removing Java from my machine to get past it but fixing the project is probably a more sustainable route.

@adamdecaf

Yep. I missed that before, sorry. I don’t have a windows machine to test with, but could y’all try this patch?

@nickkaczmarek

@adamdecaf

Ah okay. If the install path for java (or the extracted file structure) is different for windows we can probably work around the differences.

@cretz

If the install path for java (or the extracted file structure) is different for windows

It’s not. The difference is JRE vs JDK.

@adamdecaf

That makes sense. Do you know if the structure is the same across OS’s? We could just check for both paths.

Дополнительно:  Key Root Master APK v1.3.6 (RaiMod) Download

@cretz

@Suleman-Elahi

image

@zanjs

ERROR: failed to execute "keytool -list": exec: "": executable file not found in %PATH%

@nickkaczmarek

@adamdecaf

Why would we opt out of java? It’s been useful at a previous employer to add the company CA into the truststore.

@nickkaczmarek

@FiloSottile

To be clear, when JAVA_HOME is set, both the Java and the system trust stores have the certificate installed. Would you still want to selectively disable that, even if this issue was fixed? If so, please open a separate issue for that feature request.

@nickkaczmarek

@nickkaczmarek

In any case, I have this working on my mac at home and windows pc at work and I’m so glad there is such a simple tool to do this. I’ve seen there are others, but this piques my interest especially since it’s written in go.

@nickkaczmarek

@FiloSottile

Thanks everyone, let me know if v1.1.1 fixes this.

@wikijm

For Windows installation, you can use those commands:

 Define %JAVA_HOME% variable
     /d   ()   

 Add %JAVA_HOME% VARIABLE to %PATH% variable
      ; -m

@OwenMelbz

I had the same issue today on Mojave.

I ended up manually running keytool to kick it into action by doing keytool -genkeypair which fixed the keytool error: java.lang.Exception: Keystore file does not exist error.

However then still had the odd JAVA_HOME issue — I used a pretty dodgy workaround and added an bash alias of alias mkcert="unset JAVA_HOME && mkcert"

So just for that terminal session it would unset it — and it seems to then work!

@noway

unset JAVA_HOME did the trick for me

@pedrovgs

I just deleted JAVA_HOME env var and it just worked like a charm. Thanks!

Оцените статью
Master Hi-technology
Добавить комментарий