Use gradle.properties for central version numbers and build configurations
suggest changeYou can define central config info in
- a separate gradle include file http://stackoverflow.com/documentation/android/95/gradle-for-android/2911/centralizing-dependencies
- a standalone properties file http://stackoverflow.com/documentation/android/95/gradle-for-android/7837/versioning-your-builds
or do it with the root gradle.properties file.
The project structure
root
+- module1/
| build.gradle
+- module2/
| build.gradle
+- build.gradle
+- gradle.properties
Global settings for all submodules in gradle.properties
# used for manifest
# todo increment for every release
appVersionCode=19
appVersionName=0.5.2.160726
# android tools settings
appCompileSdkVersion=23
appBuildToolsVersion=23.0.2
usage in a submodule
apply plugin: 'com.android.application'
android {
// appXXX are defined in gradle.properties
compileSdkVersion = Integer.valueOf(appCompileSdkVersion)
buildToolsVersion = appBuildToolsVersion
defaultConfig {
// appXXX are defined in gradle.properties
versionCode = Long.valueOf(appVersionCode)
versionName = appVersionName
}
}
dependencies {
// other dependencies
}
Note: If you want to publish your app in the F-Droid app store you have to use literal version numbers in the gradle file, because otherwise the F-Droid scanner cannot read the current version number to detect and verify version changes.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents