I am trying to create a new Keystore to generate a signed apk but I am getting an error like this, please help me to get rid of this error.
This is a known issue with Android Studio 4.2. It runs on JDK11 which has this limitation.
Google's own documentation on app signing states that the key password "should be different from the password you chose for your keystore" so I'm guessing they intend to fix this at some point.
The key store password and key password should be the same in order to avoid this error. However before I was able to release and deliver apps where key store password and key password are different and I still use it today when updating my apps. If anyone can point out what happened here or is this a part of update before and after the new Android Studio Arctic Fox please provide some source.
keytool
) developed by Oracle. Oracle guys really think that having two different passwords for the key and the keystore is not the way to go. It will never be fixed. Use some other tool if you value security. –
Watertight I got caught by this after upgrading to Android Studio 4.2 too.
One workaround I found is to first create the keystore file with the same password in Android Studio then switch to an old JDK (pre 11) and use the keytool
command to update the key password.
- Find and use an old version of Java (Sorry assumes Mac or Linux but setting
JAVA_HOME
on Windows should work too.)$ /usr/libexec/java_home -V $ export JAVA_HOME=$(/usr/libexec/java_home -v OLD_VERSION)
- Run
keytool
to update your key password.$ keytool -keypasswd -keystore PATH_TO_KEY_STORE -alias ALIAS -storepass STORE_PASSWORD -keypass OLD_KEY_PASSWORD -new NEW_KEY_PASSWORD
keytool error: java.lang.UnsupportedOperationException: -keypasswd commands not supported if -storetype is PKCS12
–
Desired Android Studio Version 4.2 Update
Now Android Studio runs on JDK 11. Due to these changes, the signing keys issue is coming.
Solution
Use the same password for both the Key and Keystore.
All of these answers make it sound like this is a bug in latest Android Studio or keytool
and all provide "workarounds". But using PKCS12 with same key/store password is the desired and correct behavior. See the comment from the linked bug filing
The only thing that is incorrect is Android's outdated doc to use separate PWs.
I was very surprised when I entered the same with key password and password and got the right result. and jks file created successfully in android studio 4.2.
This issue occurred in android studio 4.2. it has the solution to solve this issue in android studio 4.0.
Follow the steps.
Click help menu in android studio, click Edit custom VM options, thi action response to open the file studio64.exe.vmoptions.
In this file add the below command line:
custom Android Studio #.vmoptions, see https://developer.android.com/studio/intro/studio-config.html
Or Upgrade latest version.
Note: to work around this issue, enter the same password for both the key and keystore.
From JDK
version 9 default key format is set to PKCS12
see link.
To create key with different keystore and key passwords use keytool
(note the -storetype JKS
tag) and then choose that key you've created in Android Studio (during creation replace every string that starts with CHANGE_
in the example below):
keytool -genkey -v -alias CHANGE_KEY_ALIAS -keyalg RSA -keysize 2048 -validity 10000 -storetype JKS -dname "CN=CHANGE_FIRST_NAME_LAST_NAME,OU=IT,O=CHANGE_ORGANISATION_NAME,L=CHANGE_LOCATION_CITY_NAME,C=CHANGE_COUNTRY_CODE" -keystore CHANGE_KEYSTORE_NAME.keystore -keypass CHANGE_KEY_PASSWORD -storepass CHANGE_KEYSTORE_PASSWORD
About the key password, the doc says :
This should be the same as your keystore password. (Please refer to the known issue for more information)
And from https://developer.android.com/studio/known-issues#ki-key-keystore-warning :
To work around this issue, enter the same password for both the key and keystore.
From my understanding it is just Android Studio UI that is misleading (probably needs to be updated).
© 2022 - 2024 — McMap. All rights reserved.
Won't Fix
: bugs.openjdk.java.net/browse/JDK-8008292 – Rafferty