Sheng Gao
Sheng Gao

Reputation: 61

Flutter release APK:Invalid keystore format with Linux(deepin)

I try release APK with Flutter,but went wrong:

Execution failed for task ':app:packageRelease'.

Failed to read key key from store "/home/jerome/key.jks": Invalid keystore format

My storePassword and keyPassword is right.enter image description here

Upvotes: 2

Views: 1474

Answers (3)

Danny Apostolov
Danny Apostolov

Reputation: 497

It seems that it's really important to generate the keystore with a very particular version of the keytool executable. On my Windows machine, a search for keytool.exe yielded lots of results:

c:\Program Files\Android\Android Studio\jre\bin\keytool.exe

c:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\bin\keytool.exe

c:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\jre\bin\keytool.exe

c:\Program Files (x86)\Java\jre1.8.0_301\bin\keytool.exe

c:\ProgramData\Sony Mobile\Update Engine\{5152617D-088D-4700-97C9-A2696A37E999}\jre\bin\keytool.exe

c:\Users\All Users\Sony Mobile\Update Engine\{5152617D-088D-4700-97C9-A2696A37E999}\jre\bin\keytool.exe

For my React Native application, I initially created the keystore with c:\Program Files (x86)\Java\jre1.8.0_301\bin\keytool.exe assuming that this would the be most authorative Java installation, and got the "Invalid keystore format" error.

The solution was to go with c:\Program Files\Android\Android Studio\jre\bin\keytool.exe. The rationale behind this would be to use the same Java installation as the build engine (in my case - gradlew bundleRelease).

(Copy pasted my answer from here: How to solve invalid keystore format in android studio?)

Upvotes: 0

Frederic Blanc
Frederic Blanc

Reputation: 71

I had this issue as well using VSCode.

Choicodes answer solved the issue, then running % flutter build appbundle --release

Produced the aap required for production in Play store console

Upvotes: -2

choicodes
choicodes

Reputation: 91

I had this issue as well. I'm using android studio.

I unnecessarily installed a java JDK and used that to generate a keytool, which is incorrect because you are supposed to use the one provided from Android Studio.

Steps:

  • flutter doctor -v

  • Should see a Java binary at: under Android toolchain, this is the dir where your keytool is location, mine was /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java

  • Replace java with keytool so in this case /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool

  • Run it directly, in my case I ran /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

  • Follow prompt

  • The key.jks file will appear in your main dir. Normally somewhere in /Users/<username>/key.jks

  • Now build your android app with this keytool should solve your problem

Upvotes: 9

Related Questions