您的位置:首页 > 其它

如何在编译过后自动签名apk

2014-03-01 09:58 134 查看
1、使用keytool创建android的keystore

keytool -genkeypair -v -keystore android.keystore -alias android -keyalg RSA -validity 20000

-genkeypair 生成密钥对

-v 详细输出

-keystore <keystore> 密钥库名称

-alias <alias> 要处理的条目的别名

-keyalg <keyalg> 密钥算法名称

-validity <valDays> 有效天数

2、将生成的android.keystore写入ant.properties文件

# You can also use it define how the release builds are signed by declaring

# the following properties:

# 'key.store' for the location of your keystore and

# 'key.alias' for the name of the key to use.

# The password will be asked during the build when you use the 'release' target.

key.store=D:\\tank\\MyKeystore.ks

key.alias=myalias

key.store.password=123456

key.alias.password=123456

添加创建时的密码 ,当创建批处理文件时可以自动添加。

3、使用ant进行编译

ant release

未对齐的apk:xxx-release-unaligned.apk

对齐后但未签名的apk:xxx--release-unsigned.apk

生成签名的apk:xxx-release.apk

【注】对齐的APK,就是使它所有没有被压缩的资源都4bytes对齐,这样提高API访问这些资源的速度。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: