Reputation: 123
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
Upvotes: 7
Views: 33869
Reputation: 41
this worked for me.
Delete and Regenerate Debug Keystore The simplest way to resolve this issue is to delete the debug keystore. Android Studio will automatically generate a new one when you build your project again.
Upvotes: 3
Reputation: 1
I had the exact same problem, for me the solution was just to update the java version and then create new keystore from that new version and thankfully the keystore it created was compatible with the build tools version 33.0.2 which I was using to sign apk.
Upvotes: 0
Reputation: 12589
The embedded Java version should always work and not have problems with the keys:
For some reason this was set to "11" above, it was the same version, but reported problems. In the attempt to find the right version, I got this error reported by OP, though. I think the embedded JDK version is the recommend one.
Upvotes: 0
Reputation: 6329
I ended up getting the Zulu Java version because apparently it works better with Macbook M1.
Install SdkMan from sdkman.io
Then to switch your Java version:
sdk install java 11.0.13-zulu
sdk use java 11.0.13-zulu
(You can always use sdk java list
to see what you have installed & what you can install etc.)
Then the most important part, ensure your Android Studio is using that Java version - go into Preferences (Android Studio > Settings) and search Gradle, then go to where it says "Gradle JDK" & select the right one.
Upvotes: 3
Reputation: 1075
I had the same problem because I was using the android studio with the default JDK and when I changed the JDK to a different one and tried to run the app using the terminal it always failed.
Solution:
"keytool -genkey -v -keystore debug.keystore -storepass android
-alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
Upvotes: 0
Reputation: 544
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.
Remove or rename your current keystore (.jks
file)
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
bin
folder where java
is located (your path may differ)cd /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/
https://flutter.dev/docs/deployment/android#create-an-upload-keystore
Upvotes: 2
Reputation: 1196
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
}
}
Upvotes: 4
Reputation: 681
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.
Upvotes: 5
Reputation: 214
You need to generate the key with android studio.
I got the same issue, the keytool on my M1(OpenJDK) generates invalid key.
Upvotes: 4