android re-sign APK file

1.       Generate Android  APK package signing certificate

1). Switch to the bin directory of jdk in doc     

cd C:\Program Files\Java\jdk1.6.0_18\bin

2). Run the following command     

keytool –genkey –alias android123.keystore –keyalg RSA –validity 20000 –keystore android123.keystore

/* Explanation: The keytool tool is the certificate tool that comes with the Java JDK

The -genkey parameter means: to generate a certificate (copyright, identity security certificate)

The -alias parameter indicates that the certificate has an alias, and -alias mine.keystore indicates that the certificate alias is : mine

-keyalg RSA indicates the encryption type, RSA indicates that encryption is required to prevent others from stealing

-validity 20000 means valid for 20000 days (K3

-keystore mine123.keystore indicates that the name of the certificate to be generated is mine123

*/

 

After entering the carriage return, the screen displays: : a4 x: O. i5 I

Enter the keystore password: [ password will not be echoed ] (usually it is recommended to use 20 digits, it is best to write it down and use it later)

Enter the new password again: [ password not echoed ] ( o' ^$ _( F( K& I0

What is your first and last name?

[Unknown] lili # E # C/ Z! O) I; K6 r7 M-

What is your organizational unit name?

[Unknown]snoopy' |3 v& I! _/ l

What is the name of your organization?

[Unknown]snoopy team

What is the name of your city or area? ) L# V' |. E0 f; {

[Unknown]beijing

What is the name of your state or province?

[Unknown]beijing

What is the two-letter country code for this unit

[Unknown]CN- m. ~1 W. i0

CN=lili, U=snoopy, O=snoopy team, L=beijing, ST=beijing, C=CN正确吗?

[]Y

输入< mine.keystore>的主密码

(如果和keystore密码相同,按回车):

 

 

查看C:\Program Files\Java\jdk1.6.0_18\bin,生成了以后签名用的证书Keymine123.keystore

 

 

2.      删除之前的签名文件

1).     用解压工具解压缩apk文件(如:解压到D:\Sign\PhoneBook

 

 

压缩包内容解析:

(1)     META-INF目录:存放签名后的CERTMANIFEST文件,用于识别软件的签名及版权。

(2)     res目录:存放各种Android原始资源,包括:动画anim、图片drawable、布局layoutmenu菜单、xml等等

(3)     AndroidManifest.xml编码后的Android项目描述文件,包括了Android项目的名称、版本、权限、程序组件描述等等

(4)     classes.dex编译后Classdx程序转换成Dalvik虚拟机的可执行字节码文件

(5)     qresources.arsc所有文本资源的编译产物,里面包含了各Location对应的字符串资源。

 

2).     找到下面的目录META-INF,删除目录META-INF

3).     PhoneBook整个文件夹用zip工具,重新打包成zip压缩包,然后更改后缀为apk (注意:产生的PhoneBook.zip中没有二级根目录)

 

 

3.      重新签名APK文件

1).     将证书复制到与需要重新签名的apk文件相同的目录下(如:复制到D:\Sign

2).     doc中切换到需要重新前面的apk文件的目录下

cd D:\Sign

3).     运行下面的命令

jarsigner –verbose –keystore mine123.keystore –signedjar PhoneBook_signed.apk PhoneBook.apk mine.keystore

/*解释:* ^, {& k1 Z. M* P/ M+ K5 n5 hjarsignerJava的签名工具# K8 ~% s# Y. @6 P

-verbose参数表示:显示出签名详细信息

-keystore表示使用当前目录中的mine123.keystore签名证书文件。

-signedjarPhoneBook_signed.apk表示签名后生成的APK名称,% v! a7 e2 v4 W# ]; GPhoneBook.apk表示未签名的APK Android软件, mine.keystore表示别名

*/

 

输入完回车后屏幕如下图显示:

 

 

查看D:\Sign目录,已生成重新签名后的PhoneBook_signed.apk文件

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326989281&siteId=291194637