首页 > 解决方案 > 为什么 Android Developer Bundle Tool 无法识别我的密钥库中的密钥?

问题描述

我的密钥库文件中有一个条目。我可以使用以下命令查看内容:

$ keytool -list -keystore app-signing-key.keystore
Enter keystore password:  
Keystore type: jks
Keystore provider: SUN

Your keystore contains 1 entry

appsigning, Sep 8, 2021, trustedCertEntry, 
Certificate fingerprint (SHA1): D:....<the sha1 here>...:D

我正在尝试使用此条目来使用 java bundle 工具和以下命令创建 apk,但我收到一个错误,即找不到该条目。

$ java -jar $HOME/bin/bundletool-all-1.8.0.jar build-apks --bundle ./app-release.aab --output app.apks --connected-device --ks ./app-signing-key.keystore --ks-key-alias=appsigning
Enter keystore password: 
[BT:1.8.0] Error: No key found with alias 'appsigning' in keystore.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: No key found with alias 'appsigning' in keystore.
        at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
        at com.android.tools.build.bundletool.model.SignerConfig.readSigningConfigFromLoadedKeyStore(SignerConfig.java:184)
        at com.android.tools.build.bundletool.model.SignerConfig.extractFromKeystore(SignerConfig.java:140)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.populateSigningConfigurationFromFlags(BuildApksCommand.java:1127)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:599)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:565)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:77)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)

这很奇怪。

为什么 bundletool 看不到使用别名的条目?

标签: androidandroid-app-signingbundletool

解决方案


您必须为您的密钥库提供别名,例如:

keytool -list -keystore app-signing-key.keystore -alias KEY_ALIAS_HERE

如果您未指定任何KEY_ALIAS内容,则默认别名为“appsigning”。


推荐阅读