平时通过Eclipse生成在bin目录下的apk文件,都是debug版的,如何创建release版的软件呢?
其实还是挺简单的。
1. 通过java自带的keytool工具,创建release版的keystore
- keytool -genkey -v -keystore keystore_name.keystore
- -alias alias_name -keyalg RSA -validity 10000
keytool -genkey -v -keystore keystore_name.keystore
-alias alias_name -keyalg RSA -validity 10000
keystore_name.keystore:要创建的release版keystore的文件名
alias_name:别名?取个好记点的名字吧,后面还要用到的
-keyalg RSA:通过RSA算法生成
-validity 10000:有效期,单位是天
如果java环境配置正常,输入命令后会出现下列信息
Enter keystore password:(keystore的密码)
Re-enter new password:(确认keystore的密码)
What is your first and last name?
[Unknown]: (姓名,用自己喜欢的名字吧,不知道会显示在哪里)
What is the name of your organizational unit?
[Unknown]: (组织单位)
What is the name of your organization?
[Unknown]: (组织,不知道和上面那个有什么区别)
What is the name of your City or Locality?
[Unknown]: (城市)
What is the name of your State or Province?
[Unknown]: (州,省,县)
What is the two-letter country code for this unit?
[Unknown]: CN
Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CN correct?
[no]: yes (确认输入的信息)
Generating 1,024 bit RSA key pair and self-signed certificate (SHA1withRSA) with
a validity of 10,000 days
for: CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CN
Enter key password for <alias_name>
(RETURN if same as keystore password):(alias的密码,如果和keytore密码一致,直接回车)
Re-enter new password:(确认alias的密码)
[Storing my-release-key.keystore]
2. 创建release版的apk文件
在Eclipse中,右键要发布的项目,依次选择Android Tool -> Export Signed Application Package...
然后就是step-by-step了,选择刚才生成的release版keystore,输入密码,选择alias,输入alias密码,生成release版的apk。