APK signing error : Failed to read key from keystore

AndroidGradleApk

Android Problem Overview


I'm developing android app under intellij and gradle. and using following way to generate keystore file:

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

then used the keystore file in build.gradle:

signingConfigs {
    robert {
        storePassword 'robert'
        storeFile file('/Users/bournewang/Documents/Project/android.keystore')
        keyPassword 'robert'
        keyAlias 'mike'
    }
}

when finally trying to generate signed apk file: ./gradlew assembleRelease

it gives the error:

Execution failed for task ':Myexample:packageRelease'. > Failed to read key from keystore

Android Solutions


Solution 1 - Android

In order to find out what's wrong you can use gradle's signingReport command.

On mac:

./gradlew signingReport

On Windows:

gradlew signingReport

Solution 2 - Android

Check your keystore file for first, in you example you creating file with name my-release-key.keystore. If its correct and really present in folder Users/bournewang/Documents/Project check alias, in your example it is -alias alias_name, but in config you specified alias mike

Solution 3 - Android

Most likely that your key alias does not exist for your keystore file.

This answer should fix your signing issue ;)

Solution 4 - Android

Removing double-quotes solve my problem, now its:

DEBUG_STORE_PASSWORD=androiddebug
DEBUG_KEY_ALIAS=androiddebug
DEBUG_KEY_PASSWORD=androiddebug

Solution 5 - Android

In my case, while copying the text from other source it somehow included the space at the end of clipboard entry. That way the key password had a space at the end.

Solution 6 - Android

In Android Studio go to Build > Clean Project then re-generate signed APK using Build > Generate Signed Bundle / APK... and then clear password-fields and re-enter your passwords

Solution 7 - Android

For someone not using the signing configs and trying to test out the Cordova Release command by typing all the parameters at command line, you may need to enclose your passwords with single quotes if you have special characters in your password

cordova run android --release -- --keystore=../my-release-key.keystore --storePassword='password' --alias=alias_name --password='password'

Solution 8 - Android

The big thing is either the alias or the other password is wrong. Kindly check your passwords and your issue is solved. Incase you have forgotten password, you can recover it from the androidStuido3.0/System/Log ... Search for the keyword password and their you are saved

Solution 9 - Android

Make sure you have correct the folliwn

  • keystore file path
  • keystore alies name
  • keystore password

keystore in android/key.properties

enter image description here

Solution 10 - Android

in my case for some reason, after updating android studio to the last stable version, the password that was always by default got changed, i just had to set correct password again and it worked

Solution 11 - Android

Depending on where you generated the keyfile, keytool might refer to a different binary, running on a different JVM version. These are not necessarily compatible, try adjusting the versions.

Solution 12 - Android

I got same error today.

>Execution failed for task ':app:packageRelease'. > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable > com.android.ide.common.signing.KeytoolException: Failed to read key news from store "E:\keystore\news.jks": Keystore was tampered with, or password was incorrect

I had same key password and key store password. But i wrote a wrong password.

Solution 13 - Android

It could be any one of the parameter, not just the file name or alias - for me it was the Key Password.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLiangWangView Question on Stackoverflow
Solution 1 - AndroidTom SuselView Answer on Stackoverflow
Solution 2 - AndroidcooperokView Answer on Stackoverflow
Solution 3 - AndroidStephen VinouzeView Answer on Stackoverflow
Solution 4 - AndroidfincodeView Answer on Stackoverflow
Solution 5 - AndroidStjepan GolemacView Answer on Stackoverflow
Solution 6 - AndroidMTMView Answer on Stackoverflow
Solution 7 - AndroidMohamed AzherView Answer on Stackoverflow
Solution 8 - AndroidDaniel NyamasyoView Answer on Stackoverflow
Solution 9 - AndroidUmer Waqas CEO FluttydevView Answer on Stackoverflow
Solution 10 - AndroidkariqueView Answer on Stackoverflow
Solution 11 - Androidphil294View Answer on Stackoverflow
Solution 12 - AndroidRohaitas TanoliView Answer on Stackoverflow
Solution 13 - AndroidA-SView Answer on Stackoverflow