[Original] Android automatic packaging command line packaging

Source: Internet
Author: User

Android Automatic Packaging process detail diagram:

Here are a few steps to summarize:

1. Generate R file 2. Java code is compiled into class file 3. class file generates DEX file 4. Packaging Resources 5. Generate Apk6. Create key 7. Signature apk under the Ubuntu command line to package, the process is as follows: 1. Generate the R file with the following command:AAPT package-f-m-j$BUILD _source_path/$ANDROID _gen \ -A$BUILD _source_path/$PACKAGE _resource_file \ -S$BUILD _source_path/$ANDROID _resource_directory \ -I.$BUILD _api_level_jar \ -M$BUILD _source_path/$MANIFEST _file -F If the compiled generated file already exists, force overwrite.
-M causes the directory of the generated package to be stored in the directory specified by the-J parameter
-J Specifies the output directory path of the generated R.java
-s specifies the path to the Res folder-i specifies the path to the Android.jar file for a version of the platform-a specifies the path of the Assert folder 2. Compile the Java code into a class file with the following command line:Javac-encoding UTF-8\-target 1.7\-bootclasspath$BUILD _api_level_jar \ -D$BUILD _source_path/$ANDROID _bin/$ANDROID _bin_classes \ $BUILD _source_path/$ANDROID _gen/com/clarck/httpclientnew/r.java \ $BUILD _source_path/src/com/clarck/httpclientnew/*.java-encoding < encoding > Specifying encoding Format-target < version > Generate a class file for a specific VM version
-bootclasspath < path > Overwrite the location of the boot class file
-D < directory > Specify the location where the generated class files are stored
-sourcepath < paths > Specify where to find the input source files 3. The class file generates the Dex file with the following command line:DX--dex--output=$BUILD _source_path/$ANDROID _bin/$ANDROID _classes_dex \ $BUILD _source_path/$ANDROID _bin/$ANDROID _bin_classes --output=< The Classes.dex path to be generated > < path to the class file to be processed > 4. Package the resources with the following command line:AAPT Package-f-M$BUILD _source_path/$MANIFEST _file \ -S$BUILD _source_path/$ANDROID _resource_directory \ -A$BUILD _source_path/$PACKAGE _resource_file \ -I.$BUILD _api_level_jar \ -F$BUILD _source_path/$ANDROID _bin/byreadreader -F If the compiled generated file already exists, Force overwrite
-m specifies the path of the Androidmanifest.xml
-S Specify the Res folder path-i specifies the path of the Android.jar for a version of the platform-f specifies the full path of the output file 5. Build the APK with the following command line:Apkbuilder$BUILD _apk_path/$BUILD _apk_name \ -v-u-Z$BUILD _source_path/$ANDROID _bin/byreadreader \ -F$BUILD _source_path/$ANDROID _bin/$ANDROID _classes_dex \ -rf$BUILD _source_path/$ANDROID _src -V Verbose Show process information
-U Create a non-signed package
-Z Specify APK resource path
-f Specifies the Dex file path-RF the specified source path 6. Create the key with the following command line:Keytool-genkey-alias release-keyalg rsa-validity 20000-keystore release.keystore-genkey Create a default file in the user home directory. Keysto Re "also generates a MyKey alias that contains the user's public key, private key, and certificate MyKey
-alias Generating aliases
-keyalg the algorithm that specifies the key
-validity specifies how many days to create a certificate validity period
-keystore Specifies the name of the KeyStore (the resulting types of information will not be in the. keystore file) 7. Signature apk, command line as follows:Jarsigner-verbose-keystore Release.keystore-storepass [Email protected]#$%^-keypass [email protected]#$%^-signedjar $BUILD _apk_path/$BUILD _release_apk_name $BUILD _apk _path/$BUILD _apk_name release -verbose output details when signing/validating
-keystore KeyStore Location
-storepass password for key-store integrity
-keypass Password for private key (if different)
-signedjar the name of the signed JAR file (the first apk is the file after the signature, the second apk is the one that needs to be signed) Note: For confusing code, you only need to specify the. Pro file to be confused in project.properties.
The above command can be combined with a shell script to execute, the specific demo see: Https://github.com/clarck/CommandAutoBuild
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.