1, create certificate
Step 2 sign
3. Optimization (optional)
1) use jdk's keytool tool to generate a signed certificate >: keytool-genkey-v-alias cert-keyalg RSA-keysize 2048-validity10000-keystore cert. Keystore needs to enter some identification information and passwords during the creation process. Some important parameter values are described as follows (which can be modified according to your own needs): CERT.keystore-file name of CERTificate cert-certificate alias 10000- validity period 10000 days 2048- default value is 1024 bits. Android recommends using 2048 bits or higher. For other details, you can use keytool -help to view help. After the certificate is generated, you can use the following command to view the information of the certificate: > keytool-list-alias cert-keystore cert.keystore.
2) use jdk's jarsigner tool to sign the apk file >: jarsigner-verbose-keystore cert signing process. The keystore to sign. Apkcert needs to enter the password of the certificate. Some important parameter values are explained as follows (modified according to your own needs): CERT.keystore-certificate file name for saving certificates CERT-certificate alias If there is a folder "META-INFO" under the root directory of the apk file to be signed, you can delete "-verbose" if you don't want the creation process to output too much information. The above signature will directly overwrite the original file. If you don't want to overwrite it and sign it as another new file, just change _sign.apk to-signed jarto _ sign.apk signed.akp. After signing, you can use the following command to verify whether the signature is successful: > Jarsigner -verify to_sign.apk If more detailed verification information is needed, it can be modified to: > jarsigner-certs-verbos.
3) Optimize the signed apk file with zipalign tool of android sdk >: Zipalign-V4Unaligned. Apkaligned.apk be careful to sign before zipalign. This tool is not included in the jdk, but in% Android _ home% \ Tools \ zipalign.exe.