How do you install the keystore in flutter?

Viewed 4788

I tried to install Keystore in flutter so, inside the terminal, I wrote:

(keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key)

However, it said:

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

And it doesn't work. How can I fix it? Is there something I should add in the Environment variables? (I'm using Windows 10).

3 Answers

Let me say you a quick solution! Better open the command prompt. Go to the folder where you have installed Java. Eg: In my case, it is C:\Program Files\Java\jre1.8.0_211\bin Command Looks like this

cd "C:\Program Files\Java\jre1.8.0_211\bin"

Now try to execute your previous key tool command. If it works so, add the above path to your Environment Variables.
Further Reference: https://flutter.dev/docs/deployment/android#signing-the-app

From the documentation:

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".


For example, if I run futter -v:

...

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\Mendel\AppData\Local\Android\Sdk\tools
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = C:\Users\Mendel\AppData\Local\Android\Sdk\tools
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
...

Locate where it says "Java binary at" and replace the path \java with keytool, So if Java is installed at:

C:\Program Files\Android\Android Studio\jre\bin\java

keytool would be at:

C:\Program Files\Android\Android Studio\jre\bin\keytool

So, for example, to get the debug certificate fingerprint I ran:

"C:\Program Files\Android\Android Studio\jre\bin\keytool" -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

Here mate click me!

Also you can find out more about exporting your app and making it ready for publishing there.

Related