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