The keystore was tampered or password was incorrect , error typically occurs when you try to create signed apk using keystore with the incorrect password or when keystore has been modified in some way.
Open you terminal on Mac and run this command to setup apksigner.
export PATH="$PATH:$HOME/Library/Android/sdk/build-tools/34.0.0"
We will use apksigner later on to verify signed apk alias and other details.
You can also find apksigner in Android Studio -> Preferences -> Android SDK Location -> Build Tool.
Once your apksigner setup is done , you can test it on you terminal with this command. It will print your apksigner version.
apksigner --version
Now go to your keystore.jks file and right click on it and then click on option button. Copy ….. as pathname will appear in the tool tip. Copy the location.
Now we will change keystore password and alias.
Open your terminal and write this command
The KeyStore password and The Key password should be the same.
- Change KeyStore password
keytool -storepasswd -new your_new_password -keystore your_keystore_file_location.jks
Note: Supply old passwords when asked for them
- Change Alias key Password
keytool -keypasswd -alias your_old_alias -new your_new_alias -keystore your_keystore_file_location.jks
Note: Supply old passwords when asked for them
Verify keystore with the updated alias.
keytool -list -keystore your_keystoer_location.jks -storepass new_password -alias new_alias
Create Signed apk with latest alias and password.
Verify your apk with apksigner
apksigner verify --print-certs your.apk