Detailed explanation and example code of Android custom gradle property
Android custom gradle property
Running the project on Android studio, the configuration of gradle is essential, but with the gradual growth of the project, the whole gradle becomes very chaotic due to the addition of various dependency packages, countless signatures, channel packages, etc, In this way, in fact, we can separate part of the gradle and put it in another custom gradle. For example, the plugin we added at this time can only be assigned a value
It should be noted that when adding additional properties to project in the dependencies.gradle file, we cannot define them directly, but should define them through ext.
Generally, we use closure. The code is as follows:
You can also do without closures
Of course, gradle already provides many custom properties, some of which are commonly used:
Project: project itself
Name: the name of the project
Description: project description
Version: the version number of the project
Path: absolute path of project
Builddir: storage directory of project construction results
Add in the root directory under build.graile
Next, add dependencies under build.gradle that knows the app project as follows:
Of course, other can also be configured, such as defaultconfig
The defaultconfig under the current app refers to the parameters configured by dependencies.gradle
Thank you for reading, hope to help you, thank you for your support to this site!