HotIceCream HotIceCream - 3 months ago 8
Android Question

How to define common android properties for all modules using gradle

I create a simple project in AndroidStudio with a few modules. Each module's gradle script contains the following code:

android {
compileSdkVersion 18
buildToolsVersion "18.1.1"

defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
}


How can I move this code to the main build.gradle script (project's script)? This code is common for all the submodules.

Answer

In build.gradle of main project you should write something like next:

project.extensions.add("buildToolsVersion", "19.0.3")

In subproject you can use this extensions:

buildToolsVersion rootProject.buildToolsVersion

More info you can find here

Comments