APK compilation process
The official figure
Android code (dex file) compilation process
Network spread more complete picture, part of the details may be different
The Android APK compilation process can be divided into two parts: 1. Compilation of resources 2. Compilation of code
So library is generated through NDK compilation. So file directly into the APK
Compile resource
All files under the res directory in the project 2. Files under assets directory 3. Andoird manifest file Androidmanifest.xml
The code to compile
The code compilation part includes 1. Java source file 2. Compiled Java class library and JAR package 3. A compiled class library with Android resources is the AAR package 4.r class
The R class is generated by aAPT when the resource resource is compiled
Java source files need to be compiled into class files through javac tools, and then the class files and all jar packages, including the class files in AAR packages, are compiled into DE files through dx and D8 compilers
apkbuild
The compiled AAR file is finally added to the aAPT resource package generated in the first step by using the zip command
Finally, detailed resource compilation and code compilation can be found in subsequent articles
reference
Developer.android.com/studio/buil…