Java 如何使用 jarsigner 签署 apk?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21457538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use jarsigner for signing an apk?
提问by user3143901
I have very little programming knowledge.I am able to open jar signer through the command prompt then I get various jar signer options,which i do not know how to use them.Can anyone explain me what should i type in the command prompt in order to sign the app?
我的编程知识很少。我能够通过命令提示符打开 jar signer 然后我得到各种 jar signer 选项,我不知道如何使用它们。谁能解释一下我应该在命令提示符中输入什么签署应用程序?
回答by Rahul
Use the jarsigner as below:
使用 jarsigner 如下:
jarsigner -keystore <keystore_file> -storepass <storepassword> <filenameTosigned> <alias>
回答by TomTasche
You can find all the information you need about this topic on d.android.com: http://developer.android.com/tools/publishing/app-signing.html#signapp
您可以在 d.android.com 上找到有关此主题的所有信息:http: //developer.android.com/tools/publishing/app-signing.html#signapp
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore
my_application.apk alias_name
One thing that cost me a few hours already, but is also mentioned in the official documentation:
一件事已经花费了我几个小时,但在官方文档中也提到了:
As of JDK 7, the default signing algorithim has changed, requiring you to specify the signature and digest algorithims (-sigalg and -digestalg) when you sign an APK
从 JDK 7 开始,默认签名算法已更改,要求您在签名 APK 时指定签名和摘要算法(-sigalg 和 -digestalg)
回答by demosthenes
For -tsa option enter the next one:
对于 -tsa 选项,输入下一个:
jarsigner -verbose **-tsa http://timestamp.comodoca.com/rfc3161** -sigalg SHA1withRSA -digestalg SHA1 -keystore your_keystor_name.keystore YourAPK.apk youralias_key