Created
August 13, 2015 02:54
-
-
Save gengen1988/e5aac8a9ae259134a20a to your computer and use it in GitHub Desktop.
android 签名方法,用于自动化编译流程
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 私钥别名 | |
ALIAS=alias_name | |
# 私钥存储密码 | |
STOREPASS=password | |
# 要签名的 APK 文件位置 | |
APK_FILE=my_application.apk | |
# 私钥存储的路径,注意私钥不能丢,否则以后无法更新 | |
PRIVATE_KEY_FILE=my-release-key.keystore | |
# 签名完成后的文件存储路径 | |
OUTPUT_FILE=your_project_name.apk | |
# 生成私钥 | |
keytool \ | |
-genkey \ | |
-keystore $PRIVATE_KEY_FILE \ | |
-alias $ALIAS \ | |
-keyalg RSA \ | |
-keysize 2048 \ | |
-storepass $STOREPASS \ | |
-validity 10000 | |
# 签名,使用 tsa 保证时间 | |
jarsigner \ | |
-tsa http://timestamp.digicert.com \ | |
-sigalg SHA1withRSA \ | |
-digestalg SHA1 \ | |
-keystore $PRIVATE_KEY_PATH \ | |
-storepass $STOREPASS \ | |
$APK_FILE \ | |
$ALIAS | |
# 对齐,减小内存使用,必须在签名后完成 | |
# 使用 google 提供的高压缩比 zlib | |
zipalign 4 \ | |
-z \ | |
$APK_FILE \ | |
$OUTPUT_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment