The command line and eclipse methods can be used to achieve APK signature and APK file optimization.

Source: Internet
Author: User

Signature steps:

1. Create a key

2. Use the key in step 1 to sign the APK

 

Implementation of key creation in command line

Keytool.exe in JDK, which is used in the JDK directory

Command line:

Keytool-genkey-alias demo. keystore-keyalg RSA-validity 40000-keystore demo. keystore

Parameter description:

-Genkey generation key
-Alias zhanglei. keystore alias zhanglei. keystore
-Keyalg RSA uses the RSA algorithm to encrypt the signature
-Validity 40000 validity period: 4000 days
-Keystore zhanglei. keystore name

 

Steps:



Use the key created in the command line to sign the APK:


 

Command line:

jarsigner -verbose -keystore zhanglei.keystore -signedjar demo_signed.apk demo.apk demo.keystore

 

 

Parameter description:
-Verbose outputs detailed signature information
-Keystore zhanglei. keystore location
-Signedjar zhanglei_signed.apk demo.apk zhanglei. keystore and key library zhanglei. keystore

 

 

 

The following shows how to create a keystore for eclipse and export the signed APK.

 

The operation directory is as follows:

Right-click Android project à export Android Application à

The steps are as follows:

 

Create a key and set a password:

 

Set some attributes of the keystore, including aliases:


 

Export an APK File


 

When releasing a new version, remember to sign it with the same keystore. As follows:

Select an existing keystore and sign it.

 

Enter the password for submission:


 

Finish:


 

Use the zipalign command to compress and optimize the APK.

 

Command line:

Zipalign-V 4 D: \ androidkeystore \ qtgxw.apk final.apk

Note:

-V [verbose output] Detailed output

 

So far, the key and optimization of the APK have ended.



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.