Android 使用不同的密钥库退出 apk
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10913207/
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
Resign apk with different keystore
提问by Rookie
Currently I'm getting the apk signed with the private keystore file but I want to sign that apk with different keystore file. How can I resign that apk..?
目前,我正在使用私有密钥库文件对 apk 进行签名,但我想使用不同的密钥库文件对该 apk 进行签名。我怎样才能放弃那个apk ..?
采纳答案by swiftBoy
you should check below SO thread
你应该检查下面的SO线程
Can I resign an .apk with a different certificate
or thisone also may help you
或者这个也可以帮助你
回答by Harsha.Vaswani
You can resign your apk with different keystore.
您可以使用不同的密钥库退出您的 apk。
Follow these steps:
按着这些次序:
Signing for release: $1.apk -> $1_release.apk"
签署释放: $1.apk -> $1_release.apk"
Step 1:Removing any previous signing
第 1 步:删除任何以前的签名
- Change the extension of your
.apk
to.zip
. - Open and delete the folder META-INF
- Change the extension to
.apk
Or
Command:zip [originalapk]
Example:zip "$1".apk -d
- 将您的扩展名更改
.apk
为.zip
. - 打开并删除文件夹 META-INF
- 将扩展名更改为
.apk
Or
Command:zip [originalapk]
示例:zip "$1".apk -d
Step 2:Signing with release.keystore:
第 2 步:使用 release.keystore 签名:
Command:
命令:
jarsigner –verbose –keystore [keystorefile] –signedjar [unalignedapk] [originalapk] alias_name
Example:
例子:
C:\Program Files\Java\jdk1.6.0_43\bin> jarsigner -verbose -keystore release.keystore -signedjar ""_unaligned.apk "".apk release
Step 3:Aligning
第 3 步:对齐
Command: zipalign -f 4 [unalignedapk] [releaseapk]
命令: zipalign -f 4 [unalignedapk] [releaseapk]
Example:
例子:
C:\Users\Downloads\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\too ls>zipalign -f 4 ""_unaligned.apk ""_release.apk
Step 4:Cleaning up
第 4 步:清理
Command: rm 4 [unalignedapk]
Example: rm "$1"_unaligned.apk
命令:rm 4 [unalignedapk]
示例:rm "$1"_unaligned.apk
Additional Commands might help:
其他命令可能会有所帮助:
- To generate new key with keytool
- 使用 keytool 生成新密钥
keytool -genkey -alias -keystore
- To list keys
- 列出键
keytool -list -keystore
Note:
笔记:
To sign our apks we have downgraded JDK from 1.7 to 1.6.0_43 update.
为了签署我们的 apk,我们将 JDK 从 1.7 降级到 1.6.0_43 更新。
Reason:
原因:
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)。
Command:
命令:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore [keystorefile] [originalapk] alias_name
回答by Aksel Fatih
You can also use the open-source apk-resigner script, which is very easy to use.
也可以使用开源的apk-resigner脚本,非常好用。
APK-resigner: https://github.com/onbiron/apk-resigner
APK-resigner: https://github.com/onbiron/apk-resigner
./signapk.sh calculator.apk ~/.android/debug.keystore android androiddebugkey
Also if you want to sign the APK with your debug key, you may use.
此外,如果您想使用调试密钥对 APK 进行签名,则可以使用。
./signapk.sh calculator.apk
回答by lingyfh
- remove old sign
zip -d xxxx.apk(your apk file) META-INF/*
- sign apk
jarsigner -verbose -keystore xxxx.keystore(your keystore) -signedjar out_sign.apk(outfile) unsign.apk(unsign apk) xxxxxalias(your alias)
- if sign apk not work and jdk >= 1.7
add params -digestalg SHA1 -sigalg MD5withRSA
jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA-keystore xxxx.keystore(your keystore) -signedjar out_sign.apk(outfile) unsign.apk(unsign apk) xxxxxalias(your alias)
- 删除旧标志
zip -d xxxx.apk(你的apk文件) META-INF/*
- 签名apk
jarsigner -verbose -keystore xxxx.keystore(your keystore) -signedjar out_sign.apk(outfile) unsign.apk(unsign apk) xxxxxalias(你的别名)
- 如果签名 apk 不起作用并且 jdk >= 1.7
添加参数-digestalg SHA1 -sigalg MD5withRSA
jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA-keystore xxxx.keystore(你的密钥库) -signedjar out_sign.apk(outfile) unsign.apk(unsign apk) xxxxxalias(你的别名)