HasaniK HasaniK - 1 year ago 202
Android Question

Issue signing Android Release Build " Failed to read key from keystore"

I'm using gradle (assembleRelease) to generate the release apk.

I have saved the keystore file in project/app/filename.keystore (Within the application)

I have specified details related to signing in gradle.properties file


My build.gradle file has the following related to signing

signingConfigs {
release {

storeFile file(RELEASE_STORE_FILE)

I have specified signing configurations in the same gradle file as below

buildTypes {
release {
signingConfig signingConfigs.release

However, when I'm trying to create the release build I keep getting following error

Error:Execution failed for task ':app:package<flavor>Release'.
> Failed to read key from keystore

I tried following

  • Giving a wrong password to see if the file can be found.Gives the following error with correct path there for I assume the file can be found.

    Failed to read key from store "": Keystore was tampered with, or password was incorrect

Appreciate your input!

Answer Source

My problem was that I had entered a random keyAlias. When trying to sign the apk using the IDE (IntlliJ Idea and Android Studio: Build menu -> generate signed APK), by clicking the ellipse button (...) next to the textbox for entering key alias, I found the correct key alias that I had earlier set for my keystore. Double check that you are not entering some ad-hoc random password and keyAlias for your keystore as they should be identical to the password and key alias you set for your keystore when creating it.

If you have forgotten either the password or the key alias, I am afraid you have to create a new keystore as you cannot read your keystore without these. I suggest saving these two properties (and attaching your keystore file) in a password manager like Lastpass, as you need them in future.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download