I'm using buildTypes and productFlavors. My app also uses an analytics tool and this tool used the versionName of my app.
How can I change the versionName per flavor? My test was
productFlavors {
google {
versionNameSuffix ".google"
}
}
but it failed. Does anybody has an idea how to custom the versionName depending on the flavor?
Update
Apparently the 2.2.0
version of Gradle Android plugin now allows setting versionNameSuffix
in productFlavors
buildType is the how of the build. flavor is the what of the build.
To do this, the Android plugin for Gradle allows you to create multiple groups of product flavors as flavor dimensions. When building your app, Gradle combines a product flavor configuration from each flavor dimension you define, along with a build type configuration, to create the final build variant.
This is still a work in progress for me, but seems to work:
productFlavors {
development {
versionName = android.defaultConfig.versionName + (System.getenv("BUILD_NUMBER") as Integer ? "-build" + System.getenv("BUILD_NUMBER") as Integer : "-developerBuild")
}
}
So we can set the versionName in defaultConfig, on the build server it sets the environmental variable BUILD_NUMBER, so ends up being like: 1.2-build1234
The production build only uses the defaultConfig so is just 1.2
, and when building on dev machines the environmental variable isn't set so its 1.2-developerBuild
Just came up with this plan tonight (so could be simplified i'm sure), so working on getting the latest source control revision added when on a dev machine, but i've seen other answers with how to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With