This works for me in Android Studio 0.8.9. using the default gradle wrapper 1.12-all.
App is a library used by Lite and Pro where Lite/Pro are two different flavours of the app I'm making. I wanted to share config between all modules. The global config is located in the root gradle.build file and all subprojects/modules can read these properties.
My project structure is:
Project/
gradle.build
settings.gradle
App/
gradle.build
Lite/
gradle.build
Pro/
gradle.build
In Project/gradle.build I've added a subprojects config:
subprojects {
ext.global_compileSdkVersion = 19
ext.global_buildToolsVersion = "20.0.0"
...
}
ext.[var name] adds variables whch can be read in the subprojects. I've added the prefix "global_" so it will be easier to see my properties. (Also note that I'm using an equals sign to assign the value to the variable)
In each subproject/module the gradle file looks like this:
android {
compileSdkVersion global_compileSdkVersion
buildToolsVersion global_buildToolsVersion
...
}
Note!
The Android Studio IDE doesn't seem to know about "ext" in subprojects, but gradle does. So it shows up as a warning when viewing the gradle files, but builds will still work. Because it doesn't know about "ext" it doesn't seem to know about the varables you add either, so these will also be underlined in the IDE as warnings. But it works :)