1
votes

Execution failed for task ':app:packageRelease'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade com.android.ide.common.signing.KeytoolException: Failed to read key key from store "/Users/husseinawaesha/key.jks": Invalid keystore format

4
Did you follow all the signing process for Android?Mariano Zorrilla
I walked step by step as the flutter documentsHussein
either create a new one or the one you have is brokenMariano Zorrilla

4 Answers

1
votes

You need to generate the key with android studio.

I got the same issue, the keytool on my M1(OpenJDK) generates invalid key.

0
votes

This command line statement from the Play Console Help pages will generate an Upload Keystore, you just have to substitute your own alias and supply the path to keytool...

keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks

However, while it does ask for a Store password, it does not ask for a Key password. If you are like me new to this you may not notice, and later on when you have to input a Key Password you might find yourself scrambling thru notes trying to find where you wrote it down. If you type something like keypassword as a guess it will respond with Invalid keystore format.

It is better to use the Android Studio process to generate an Upload Keystore rather than this command line statement.

0
votes

please create a key store by this code

 keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

Reference the keystore from the app

Create a file named appdir/android/key.properties that contains a reference to your keystore:

storePassword=password from previous step
keyPassword=password from previous step
keyAlias=key
storeFile=location of the key store file, e.g. 
/Users/username/key.jks

add this on app level gradile

def keystorePropertiesFile = rootProject.file("key.properties")
 def keystoreProperties = new Properties()
 keystoreProperties.load(new 
 FileInputStream(keystorePropertiesFile))

  signingConfigs {
  release {
    keyAlias keystoreProperties['keyAlias']
    keyPassword keystoreProperties['keyPassword']
    storeFile file(keystoreProperties['storeFile'])
    storePassword keystoreProperties['storePassword']
     }
       }
     buildTypes {
     release {
      signingConfig signingConfigs.release
     }
   }
0
votes

It's probably a conflict between Java versions used by Android Studio and Keytool. To solve it, re-create the keystore using Andtroid Studio's JDK.

  1. Remove or rename your current keystore (.jks file)

  2. Check Android Studio's JDK

flutter doctor -v

It'll be something like

Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
  1. Navigate to bin folder where java is located (your path may differ)
cd /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/
  1. Create new keystore:

https://flutter.dev/docs/deployment/android#create-an-upload-keystore