I always wanted to figure out how Android APK was compiled and packaged and signed to publish the application ?? Today, I spent a few hours checking information on the Internet and finally figured out the entire process of compiling and packaging APK signatures.
PS: There are three methods to complete the compilation and packaging tasks for the android program. For more information, see connection: Android compilation, packaging, and signature. I used the eclipse + ADT method, and compile the signature in cmd, hoping to help you;
1. Package unsigned APK in eclipse
In eclipse, right-click the corresponding project and choose Android tools -- export unsigned application package.
2. Pack signed APK in eclipse
In eclipse, right-click the corresponding project and choose Android tools -- export signed application package.
Next
Select the existing signature file keystore. Note that you need to know the password. If there is no keystore, You can compile a keystore by yourself in the exercise. For more information, see APK signature settings.X: \ csdn blog article \ APK packaging exercise
Create the signature file mysign. keystore step: PS: keystore is generated by the built-in JDK tool keytool.
1. Go to the CMD command line and run CD to the JDK/bin directory;
2. Enter:
Command: The mysign. keystore generated by keytool-genkey-alias asaiandroid. keystore-keyalg RSA-validity 20000-keystore asaiandroid. keystore is in the JDK/bin directory.
Explanation:-alias follows the alias. Here is asaiandroid. Store.
-Keyalg is the encryption method. Here it is RSA.
-Validity is valid. The value is 20000.
-Keystore is the name of the keystore to be generated. Here is asiandroid. keystore.
Then press enter and press Enter. The system will first prompt you to enter the password: This is used for signature. Remember it and then confirm your password. You will be asked to enter the name, organization unit, organization name, city region, province name, country code in turn
After setting the information, enter the original password again for confirmation, then enter yes/no for confirmation to complete the signature, and generate the mysign. keystore signature file;
Appendix: Search for files under cmd:
Start with unsigned.apk signature step: PS: unsigned.apk mysigned. keystore must be in the same folder. Because keytool environment variables are not configured, all the files required temporarily are placed in the JDK/binfile directory; Use jarsigner
Command: jarsigner-verbose-keystore mysign. keystore-signedjar androidtest_signed.apk androidtest.apk mysign.keystoregenerated lotteryonline_signed.apk is in the JDK/bin directory.
Explanation:-keystore: keystore name
Androidtest_signed.apk: signed APK
Androidtest.apk: APK before signature
Press enter to enter the password you just set. Press enter to start signing.
PS: Cause of the first signature failure: androidtest.apk is not in the JDK/bin directory with mysign. keystore;
Postscript:
APK Package Structure Overview: Go
Http://www.eoeandroid.com/forum.php? MoD = viewthread & tid = 100000.
Follow-up:
Keytool-genkey command explanation:
Start Android emulator in cmd:
Prerequisites: configure the environment variables for Android-SDK tools
Command: Android AVD (any directory)