Android Application (APK) Compilation and packaging process, androidapk
Flowchart: What do we focus on? (1) What is input in this process? (2) What is the output of this process? (3) what tools are used in this process? As for the parameters used, you can view the help files of the corresponding commands or search for them online. This is not the focus of this article. Aapt-> aidl-> javac-> dx (dex)-> apkbuilder-> jarsigner-> zipalign:
Name |
Features |
Path in the operating system |
Aapt |
Android resource packaging Tool |
$ {ANDROID_SDK_HOME}/platform-tools/appt |
Aidl |
Android interface description language conversion to. java file Tool |
$ {ANDROID_SDK_HOME}/platform-tools/aidl |
Javac |
Java Compiler |
$ {JDK_HOME}/javac or/usr/bin/javac |
Dex |
Convert the. class file to a. dex file that can be recognized by Davik VM. |
$ {ANDROID_SDK_HOME}/platform-tools/dx |
Apkbuilder |
Generate an apk package |
$ {ANDROID_SDK_HOME}/tools/opkbuilder |
Jarsigner |
. Jar file signature Tool |
$ {JDK_HOME}/jarsigner or/usr/bin/jarsigner |
Zipalign |
Bytecode alignment tool |
$ {ANDROID_SDK_HOME}/tools/zipalign |
Step 1: Package the resource file and generate R. java file compilation R. java classes require the aapt tool provided by AndroidSDK. There are many aapt parameters. The following are the main parameters: aapt compiling R. the java file is as follows: Enter the application directory and create a new gen directory without the gen directory. The command will fail to find the file! After the command is successfully executed, the directory tree of the Package Structure and the R. java file will be generated under the gen directory! Column: Step 2: process the AIDL file and generate the corresponding. java file (of course, there are a lot of projects that do not use AIDL, then this process can be saved. aidl file generation. java files must use the aidl tool that comes with AndroidSDK. The specific parameters of this tool are as follows: Example: Step 3: Compile the Java file to generate the corresponding. class file javac command usage: Example: javac-encoding UTF-8-target 1.5-bootclasspath E: \ Androiddev \ android-sdk-windows2.2 \ platforms \ android-3 \ android. jar-d bin src \ com \ byread \ reader \*. java gen \ com \ byread \ reader \ R. step 4 of java. the class file is converted to support by Davik VM. the dex file compiles the class file under the bin directory of the project into a class Es. dex, Android virtual machine can only execute dex files! Example: Step 5: Package the unsigned .apk file [input] The package resource file, the package class file (. dex files), libs files (including. so files, of course, many projects do not have such files. If you do not use the C/cve-example development scripts to export unsigned .apk files [tools] apkbuilder tool usage: column: apkbuilder extends output.apk. file}-u-z $ {packagedresource. file}-f $ {dex. file}-rf $ {source. dir}-rj $ {libraries. dir} Step 6: Export File [Tool] jarsigner Step 7: Align the .apk file (the file cannot be published to Google Market if no alignment is performed). Enter the. APK file after the signature. Export the corresponding. APK file. After the zipalign tool knows these details, we can implement a lot of things we want to implement. For example: automation, we can use a script like Windows batch processing, bash in linux, Ant in Java, Python, Perl, and other scripting languages, even using Java ,. net.