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

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访问这些资源的速度。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值