Why does AndroidStudio fail when Building Signed APK for Google Play (says bad password, but I've confirmed password)?

Issue

I have a Keystore (.jks) which I used to sign the previous release of my App (.APK) for Google Play. That was 1 year ago or so.

Now, when I attempt to build and use my keystore, Android Studio gives me the following incorrect error:
Could not build signed APK. Keystore was tampered with, or password was incorrect.

Android Studio version information: 
Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+0-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.11.0-49-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40)
Current Desktop: ubuntu:GNOME

Here is the functionality I’m attempting to run:

Build => Generate Signed Bundle / APK
Displays the following screens…

step 1 - build signed apk

step 2 - build signed apk

When I click [Finish] button Android Studio attempts to build & it fails with the error:

Could not build signed APK. Keystore was tampered with, or password was incorrect.

That Is an Incorrect Error

However, that is not correct because I use a password manager to store the password, so I know I have the correct password. I also kept screenshots of the last time I ran this functionality so I could confirm the key alias and it is correct also.

Things I Tried

  1. I tried rebuilding a couple of times & got the error.
  2. I closed & restarted Android Studio & still got the error.

At one point Android Studio crashed with a bug report & I tried again & it failed again.

Why does this error occur?

I discovered some other people reporting what seemed to be an issue with having a password that contained special chars (@ !, etc) at this link.

It does seem to be the same failure, but I finally got it to work & I will post the answer.

Solution

I started a console window and ran the following against my keystore.

$ keytool -list -keystore 'fakeNmae.jks' -storepass fake-password-same-one-i-used-in-android-studio

I saw the details of my keystore printed out in the console:

Keystore type: JKS Keystore provider: SUN

Your keystore contains 1 entry

fake-alias-name, Dec 15, 2019, PrivateKeyEntry, Certificate
fingerprint (SHA-256): 63:D3:69:69:39:29:5D:5E:14:20:E1:F6:FA:DF:ED
(fake data)

Warning: The JKS keystore uses a proprietary format. It is recommended
to migrate to PKCS12 which is an industry standard format using
"keytool -importkeystore -srckeystore fakeName.jks -destkeystore
fakeName.jks -deststoretype pkcs12".

Since I had to supply my password this confirmed that I was indeed using the correct password.

It also confirms that the keystore was not tampered with (corrupted).

I was a bit confused at this point.

Solution

I started AndroidStudio again & tried it again and it built the signed APK with no problem. I was able to upload it to Google Play.

Very odd. It seems that listing the details somehow fixed the issue in Android Studio. Would love to hear something about this from someone who might know why.

Maybe it has to do with that new warning about the PKCS12 format??

Answered By – raddevus

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published