Android Development: "Gradle Recipes for Android" reading notes (translation) 3.1--using build Types

Source: Internet
Author: User

Problem:

You want to customize the build types of debug and release and create some new types.

Solution:

Use the Buildtypes block to configure build types.

Discuss:

Build type determines how the app is packaged. By default, the Android Gradle plugin supports both build type:debug and release. Both are defined under the Buildtypes block in the module's Build.gradle file. The Buildtypes block under the new project is as follows:

The example median shows the build of release, but it is easy to add a debug block if you want to edit the default configuration. Each block can support the properties of some columns. The complete properties and methods can be viewed on the http://google.github.io/android-gradle-dsl/current/index.html.

In release, minifyenaled and auto-removal packages are not used in the resources involved. If set to True,gradle also removes unused dependent libraries. This only takes effect if the Shrinkrresources property is also set to true.

For more details, you can view the https://developer.android.com/studio/build/shrink-code.html page.

There is also a property called Debuggable in Buildtypes. The debug builds automatically sets Debuggable to true, and the other builds defaults to false.

In order to install the same app,android of different build types on the same device, they must be able to differentiate their app IDs. The Applicationidsuffix property allows Gradle to generate multiple apk with different IDs.

Android {buildtypes {        debug {            applicationidsuffix '. Debug '            versionnamesuffix '-debug '        }}}    

Both the release and debug versions of the app can now be installed on the same device. If you can see the device configuration, in apps, you can see that the debug and release versions are the same app.

If you want to differentiate between them, you can select each version to see the full version name in the APP info settings, respectively.

Android Development: "Gradle Recipes for Android" reading notes (translation) 3.1--using build Types

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.