说明:此方法适用在MAC中,对于windows系统,没有尝试过
1、打开终端
2、去到java安装的根目录,即输入
1
|
cd
/Library/Java/Home/bin/ |
3、当前用户没有最高权限,在Library文件夹下不能生成任何文件,可以到当前用户目录下生成文件
1
|
keytool
-genkey -v -keystore android.keystore -alias android -keyalg RSA -validity 20000 -keystore
/Users/当前用户的用户名/android_demo.keystore |
如果当前的用户名是xiaohong,则如下
1
|
keytool
-genkey -v -keystore android.keystore -alias android -keyalg RSA -validity 20000 -keystore
/Users/ xiaohong/android_demo.keystore |
4、按照提示输入即可,完整代码如下
xiaohongdeiMac:/
xiaohong$ cd /Library/Java/Home/bin/
xiaohongdeiMac:bin
xiaohong$ keytool -genkey -v -keystore android.keystore -alias android -keyalg RSA -validity
20000
-keystore
/Users/xiaohong/android_demo.keystore
Enter
keystore password:
Re-enter
new
password:
What
is your first and last name?
[Unknown]:
Liu XiaoHong
What
is the name of your organizational unit?
[Unknown]:
www.xiaohong.com
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]:
86
Is
CN=Li XiaoHong, OU=www.xiaohong.com, O=小红集团, L=上海,
ST=上海市, C=
86
correct?
[no]:
Y
Generating
1
,
024
bit
RSA key pair and self-signed certificate (SHA1withRSA) with a validity of
20
,
000
days
for
:
CN=Liu XiaoHong, OU=www.xiaohong.com, O=小红集团, L=上海,
ST=上海市, C=
86
Enter
key password
for
<android>
(RETURN
if
same
as keystore password):
[Storing
/Users/xiaohong/android_demo.keystore]
5、到这里就可以到当前用户根目录下查看生产的keystore签名文件了