APK errors

Keystore was tampered with / wrong password

Error text

java.io.IOException: Keystore was tampered with, or password was incorrect
Caused by: java.security.UnrecoverableKeyException: Failed to decrypt safe contents entry

Cause

The keystore will not open. The password is wrong, the file is damaged (for example edited as text), or the format does not match.

Step-by-step fix

  1. Retype the password carefully. Quote special characters on the command line.
  2. Inspect the file itself with keytool -list -v -keystore ....
  3. Check the file copy: was it damaged during download? Take the original.
  4. Formats differ between JDK 8 and JDK 17: convert with -deststoretype pkcs12.
  5. If the password is lost the key cannot be recovered. With Play App Signing, request an upload key reset.

Example commands

keytool -list -v -keystore my-release.jks
keytool -importkeystore -srckeystore my-release.jks -destkeystore new.p12 -deststoretype pkcs12

How to prevent it

Store the keystore file and its password in a password manager and in a second place.

Author and license: Nibras Code