简体   繁体   English

从命令行签署 Android App Bundle

[英]Sign Android App Bundle from Command Line

anyone know how to sign .aab file using new keystore from command line?有人知道如何使用命令行中的新密钥库对 .aab 文件进行签名吗? The documentation here mentions that we can use jarsigner to sign our app bundle from the command line.此处的文档提到我们可以使用 jarsigner 从命令行对我们的应用程序包进行签名。 but I cannot find the command line?但我找不到命令行? Anyone know the command line?有人知道命令行吗?

I got this error when uploaded my bundle to Google Play:将我的捆绑包上传到 Google Play 时出现此错误:

You uploaded an APK with an invalid signature (learn more about signing). Error from apksigner:

I try to sign the app bundle using this command:我尝试使用以下命令对应用程序包进行签名:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore xample.jks bundle.aab keystoreAlias

Thank you very much.非常感谢。

Probably you've already found a way to solve your problem.可能您已经找到了解决问题的方法。 Nevertheless, since it may help someone in the future, I just wanted to say that I had the same problem and changing the hashing algorithm to SHA-256 helped me to overcome it.尽管如此,由于它可能在未来对某人有所帮助,我只想说我遇到了同样的问题,将哈希算法更改为SHA-256帮助我克服了它。

jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore xample.jks bundle.aab keystoreAlias

I had the same error for another situation (or maybe the same).对于另一种情况(或者可能相同),我有同样的错误。

I was trying to re-package *.aab bundle with some changes.我试图通过一些更改重新打包*.aab包。 At first, I used a zip or jar to create an unsigned archive.起初,我使用 zip 或 jar 来创建一个未签名的存档。 After that, I signed it using jarsigner tool.之后,我使用jarsigner工具对其进行了签名。 I found that *.aab is not an ordinary zip using bundletool我发现*.aab不是使用bundletool的普通 zip

> java -jar bundletool.jar validate --bundle application.aab

[BT:0.12.0] Error: The App Bundle zip file contains directory zip entry 'base/' which is not allowed.
com.android.tools.build.bundletool.model.exceptions.BundleFileTypesException$DirectoryInBundleException: The App Bundle zip file contains directory zip entry 'base/' which is not allowed.
        at com.android.tools.build.bundletool.validation.BundleZipValidator.validateBundleZipEntry(BundleZipValidator.java:29)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundleZipFile$1(ValidatorRunner.java:47)
        at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
        at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleZipFile(ValidatorRunner.java:46)
        at com.android.tools.build.bundletool.validation.AppBundleValidator.validateFile(AppBundleValidator.java:92)
        at com.android.tools.build.bundletool.commands.ValidateBundleCommand.execute(ValidateBundleCommand.java:78)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:92)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:46)

So I used that utility to create *.aab , after that signed it using jarsigner .所以我使用该实用程序创建*.aab ,然后使用jarsigner对其进行签名。 You need to zip the contents of base/* subfolder into a separated archive.您需要将base/*子文件夹的内容压缩到一个单独的存档中。

> java -jar bundletool.jar build-bundle --modules base.zip --output application.aab

> jarsigner -keystore $KEYSTORE -storetype $STORETYPE -storepass $STOREPASS -digestalg SHA1 -sigalg SHA256withRSA application.zip $KEYALIAS

> java -jar bundletool.jar validate --bundle application.aab

App Bundle information
------------
Feature modules:
    Feature module: base
            File: assets/META-INF/AIR/application.xml
            ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM