EDITED
In order to define your app version dynamically, specify a custom method with def and call it, as such:
def computeVersionName() {
return "2.0"
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
versionCode 12
versionName computeVersionName()
minSdkVersion 16
targetSdkVersion 16
}
}
See here for more.
Make sure not to use function names that could conflict with existing getters in the given scope. For instance, defaultConfig { ... }
calling getVersionName()
will automatically use the getter defaultConfig.getVersionName()
instead of the custom method.