RePack the APK and use Jarsigner in the Java Bin directory to sign
Anti-compile Android APK package using Apktool tool, http://download.csdn.net/detail/fancylovejava/8447801
Command:
CMD>CD/D E:\apktool
Apktool d xxxx.apk will generate a file of XXXX name in the current Apktool directory, this file is the APK package anti-compiled file
Then if you want to add a file under the asset directory, you can put it under the file, but the code needs to modify the pre-written read asset logic
Then use the command Apktool B xxxx< This is the directory > then will be in the XXXX directory more dist file, which contains a repackaged apk, but this apk does not use KeyStore signature, So you need to use Java's jarsigner to sign
The command is as follows
C:\Program files\java\jdk1.8.025\bin>jarsigner-verbose-keystore keybaohuai-digestalg sha1-sigalg MD5withRSA -signedjar androidtestsigned.apk zhaocaixiong_101.apk Baohuai
A line of warnings will appear
Warning:-tsa or-tsacert not provided, this jar has no timestamp. If there is no timestamp, the user may not be able to verify the jar after the expiration date of the signer's certificate (2113-10-30) or any subsequent revocation date.
Attention
Jarsigner Signature Command Add the following parameters to solve:-digestalg sha1-sigalg Md5withrsa
Can be ignored, after installation test is feasible!
Create a key using the standard Java Tools Keytool.exe (located in the Jdk\jre\bin directory) and use the Jarsigner.exe tool to generate the certificate and sign the program (located in the Jdk\bin directory).
Win+r run cmd, enter directory D:\temp (note: Use this directory as sample working directory)
A), create can, run the following command
keytool -genkey -alias demo.keystore -keyalg RSA -validity 20000 -keystore demo.keystore
/* Description: The Keytool tool is a certificate tool that comes with the Java JDK
The-genkey parameter means: to generate a certificate (copyright, identification of the security certificate)
The-alias parameter indicates that the certificate has an alias,-alias Demo.keystore indicates that the certificate alias is: Demo
-keyalg RSA denotes encryption type, RSA means encryption is required to prevent others from stealing
-validity 20000 indicates valid time 20,000 days
-keystore Demo.keystore indicates the name of the certificate to be generated is demo
b), delete the previous signature file
Use the Unzip tool to open the APK file (for example: Change a.apk to A.zip, then use the compression tool to open and locate the Cert.rsa and CERT.SF files below the directory Meta-inf and delete the file. After deletion, change the suffix name again to. apk;)
Note:
Meta-inf directory: A signed cert and manifest file that identifies the signature and copyright of the software.
Res directory: Store a variety of Android raw resources, including: Animated anim, picture drawable, layout layouts, menu menus, XML, and more
Androidmanifest.xml encoded Android Project description file, including the Android project name, version, permissions, program component description, etc.
Classes.dex compiled class is converted by DX program to Dalvik virtual machine executable bytecode file
RESOURCES.ARSC the compilation artifacts of all text resources, containing the string resources corresponding to each location.
c), using the generated key to sign the APK, run the following command:
jarsigner -verbose -keystore demo.keystore -signedjar demo_signed.apk demo.apk demoAlias
/* Description: Jarsigner is the signature tool for Java
-verbose parameter indication: Show signature details
-keystore says: Use the Demo.keystore signature certificate file in the current directory.
-signedjar demo_signed.apk demo.apk Demo official signature, three parameters in order to produce the file after the signature
demo_signed, the file to be signed demo.apk and KeyStore demo.keystore.*/
(Note: To see if an APK has been signed, Jarsigner-verify demo.apk.) Optimization: Need to do alignment optimization after signing Zipalign-v 4 yourprojectname-unaligned.apk yourprojectname.apk)
RePack the APK and sign with Jarsigner in the Java Bin directory