Android Develop: Build System Analysis

Source: Internet
Author: User

Android Develop: Build System Analysis

The Android build system is a tool set that you use to build, test, run, and package your app. This build system can be used as an integrated tool for Android Studio menus and run in an independent command mode. You can use the following functions to build a system:

  • Customize, configure, and expand the building process;

  • Use the same project and module to create multiple Apk with different functions for your App;

  • Reuse code and resources by means of resource sets;

The Android build system is flexible, allowing you to implement all functions without modifying the core source code of your app. To learn how to build an Android Studio project, read Building and Running from Android Studio. For more information about how to customize configurations in the Android Studio project, see using ing Gradle Builds.

 

Detailed description of Build Process

Bytes ----------------------------------------------------------------------------------------

Creating a .apk involves many tools and the process of generating intermediate products. If you use Android Studio for development, the complete build process is that you complete the execution of your project or module's Gradle build task every time. The build process is very flexible, so it is very useful. However, you need to understand what happened throughout the process, because most of the build processes are configurable and scalable. The following figure depicts the related tools and processes in the building process:

The typical construction process is as follows. Build the flavor, build type, and dependent resources of different products configured for system merging. If different folders contain the same name or set resources, the following describes the priority order: dependency is superior to build type, build type is superior to product flavor, and product flavor is superior to master Resource Directory.

  • Android Asset Packaging Tool (aapt) obtains your application resource files, such as the AndroidManifest. xml file and the XML file of your Activity, and then compiles them. A r. java is generated, so you can reference your resources in your Java code;

  • The aidle tool converts all the. aild interfaces you include in the Java interface;

  • All your code, including the R. java and. aidl files, are compiled by the Java compiler to generate the. class file;

  • In the hosts file;

  • All non-compiled resources (titles, compiled resources, and .dexfiles are sent to the apkbuildertool and packaged into a .apk file;

  • The new certificate APK file is generated. A debug or release key must be used to sign the file before it is installed on the device;

  • At the end, if the application is signed under the releasemodel, you must use the zipaligntool to process the .apk file. Processing the final .apk file can reduce the memory used by applications on the device;

Note: The App has a 64 K method reference limit. If your application promotes this restriction, the following error message is output during the build process:

Unable to execute dex: method ID not in [0, 0 xffff]: 65536.

 

To avoid this error, read Building Apps with Over 65 K Methods.

 

Build output

Build an APK for each build under the app/build File plus variant: this app/build/outputs/apk directory contains the directory named app- - .Apkexample example: app-full-release.apkand app-demo-debug.apk;


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.