Android source code analysis (1) --> Android project construction process

In the usual development process, after we have finished writing the android project through android studio, we can directly click Run 'app' to generate the apk file in build/outputs/apk that can be installed in the android device, so what is the construction process of the whole android source code? Woolen cloth? We can understand the construction process in detail according to the flow chart provided by Google:

 

 



 The usual construction process is as shown in the figure above, and the following is a detailed description:

1. The AAPT (Android Asset Packaging Tool) tool will package the resource files in the application, such as AndroidManifest.xml, the xml in the layout layout, etc., and compile the xml file into binary form. Of course, the files in the assets folder will not be compiled. , the resources in the pictures and raw folders will also keep their original form. It should be noted that the resources in the raw folder will also generate resource IDs. After AAPT is compiled, the R.java file will be generated.

2. The AIDL tool will convert all aidl interfaces into java interfaces.

3. All java codes, including R.java and aidl files, will be compiled into .class files by the Java compiler.

4. The Dex tool will compile the .class file and the third library and other .class files generated above into a .dex file (the dex file is a format that can be executed by the Dalvik virtual machine), and the dex file will eventually be packaged into the APK file.

5. The ApkBuilder tool will package compiled resources and uncompiled resources (such as pictures, etc.) and .dex files into APK files.

6. After the APK file is generated, it needs to be signed before it can be installed on the device. Usually, the debug keystore is used for testing. When the application is officially released, the release version keystore must be used to sign the application.

7. If the APK is officially signed, you also need to use the zipalign tool to align the APK. The advantage of this is that the speed will be improved when the application is running, but the memory overhead will be increased accordingly. 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326021253&siteId=291194637