The Andrioid compilation system is your toolbox for Build,test,runapp. The running of the compiled system can be done through the menu of Android Studio or a separate command line. By compiling the features of the system you can do the following things:
(1) Customizing, Configuring, extending the compilation process.
(2) Create an apk with different features with the same project and modules.
(3) Reuse code and resources through source settings.
The freedom of the Android build system enables you to achieve everything you want without modifying the core source files of your application.
How to compile a project using Android Studio, see my next article Build and Running from Android Studio.
How to customize the compilation configuration, see my next article: Configuringgradle builds.
A detailed look atthe Build Process
The compilation process contains a number of tools and processes, which make it possible to generate many intermediate files during the process of compiling the APK. If you are developing in Android studio, the entire compilation process will be executed every time you run the Gradle compilation task for your app. The freedom of compiling the system makes it useful, however, because most of the build process is configurable and extensible, so we need to understand what's going on here. Describes the different tools and processes involved in the build:
A classic build process is generally as follows: The compilation system compares all of the configured product Flavors,build types,dependencies. If you include resources or settings of the same name in different folders, then the order of precedence is: dependencies overwrite build types,build types overwrite product flavors,product flavors overwrite Main Sources directory.
(1) AAPT full name Androidasset packaging tool. The tool gets the application's resource files, for example, androidmanifest.xml,activities XML files, and compiles them. The R.java file is generated, so you can use your resource file ID in Java code.
(2) Aidl tool transforms all of the. Aidlinterface you introduce in Java code.
(3) All Java code, including R.java and. Aidl, will be compiled by the Java compiler tool and then generated by the. class file.
(4) The Dex tool converts the. class file into Dalvikbyte code. Any third-party libraries and. class files will also be converted to. dex files. So that in the end they can be packaged into an. apk file.
(5) Resource slices that have not been compiled, resources that have been compiled,. dex files are sent to the Apkbuilder tool to generate the APK.
(6) Once the APK is built, it must be signed before it is installed on the device, either Debug or release.
(7) One but the APK is release, then be sure to use the zip to align tool, which can reduce the memory consumed by the APK runtime.
Note: The number of methods in the APK is limited and can not exceed 65535. Specific solutions: Please refer to my article: Apps over 64K Methods.
The author has the words: if you need the Android Chinese API, please sweep the following QR code, your concern, is my motivation, the most technical, we are serious.
Android Chinese Translation: Build System overview