简体   繁体   English

签名apk适用于Android Studio,但为什么同一个密钥库在命令行上不起作用?

[英]Signing apk works from Android Studio but why the same keystore do not work on command line?

My key for signing Android app was generated using Android Studio. 我用于签署Android应用的密钥是使用Android Studio生成的。 It is working fine when I try to generate signed APK from Android Studio. 当我尝试从Android Studio生成签名的APK时,它工作正常。

However the same key is not working when I try to sign using apksigner tool. 但是,当我尝试使用apksigner工具进行签名时,相同的密钥不起作用。 Here is the command I am using. 这是我正在使用的命令。

apksigner sign --ks mykey.jks --ks-key-alias MyAlias --out app-myapp-release.apk app-myapp-release-aligned.apk

I am getting below errors: 我收到以下错误:

java.io.IOException: Keystore was tampered with, or password was incorrect java.io.IOException:密钥库被篡改,或密码不正确

Any suggestions? 有什么建议么?

** Update ** Android Studio Version 2.2.3 The keystore was generated using "Generate Signed APK" dialog box from Build menu. **更新** Android Studio版本2.2.3密钥库是使用“生成”菜单中的“生成签名APK”对话框生成的。

I just had this exact problem, and many more while trying to sing an apk. 我只是有这个确切的问题,还有更多的尝试唱一个apk。

Try to add these options to your sign command: 尝试将这些选项添加到sign命令:

--ks-pass stdin  --key-pass stdin

Now you can normally type in your keystore password and your key (alias) password in that order. 现在,您通常可以按顺序键入密钥库密码和密钥(别名)密码。

( I cannot write comments ) so I added this as answer and hope this will help you with your issue. 我不能写评论 )所以我添加了这个作为答案,并希望这将帮助您解决问题。 Did you check these links: 你检查了这些链接:

Just for information: Your JKS file should contain the private key and the certificate meant to sign the APK, here is the official link for more details. 仅供参考:您的JKS文件应包含私钥和用于签署APK的证书 ,以下是更多详细信息的官方链接

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

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