APK 签名错误: 从密钥存储库读取密钥失败

我正在 intellij 和 gradle 下开发 android 应用程序,并使用以下方法生成密钥库文件:

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

然后使用 build.gradle 中的 keystore 文件:

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

当最后尝试生成已签名的 apk 文件时: ./gradlew assembleRelease

它给出了一个错误:

任务“ : Myexample: packageRelease”执行失败。

从密钥库读取密钥失败

165790 次浏览

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

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

On mac:

./gradlew signingReport

On Windows:

gradlew signingReport

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

This answer should fix your signing issue ;)

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

Removing double-quotes solve my problem, now its:

DEBUG_STORE_PASSWORD=androiddebug
DEBUG_KEY_ALIAS=androiddebug
DEBUG_KEY_PASSWORD=androiddebug

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.

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'

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

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.

Make sure you have correct the folliwn

  • keystore file path
  • keystore alies name
  • keystore password

keystore in android/key.properties

enter image description here

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

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

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.

For me this worked.

  1. Go to <your_app_name>/android.
  2. On the terminal use ./gradlew signingReport for Mac OS and gradlew signingReport for Windows.
  3. Check if each element of each task has a Variant, Config, Store, Alias, MD5, SHA1, SHA-256, Valid until. If so you should be good.
  4. If any of the above are absent then try to regenerate the key store by following the instructions on this page.
  5. Copy the key store file and paste it inside <your_app_name>/android/app.

Some things that I was doing wrong while generating the key store file were.

  1. Using quotations on MYAPP_UPLOAD_..._PASSWORD's.
MYAPP_UPLOAD_STORE_PASSWORD="Password123"
MYAPP_UPLOAD_KEY_PASSWORD="Password123"
  1. I used \J4ct@RD as a password and it did not work. I later changed the password to something that was just aplphanumeric and it worked.