Android Flavors — Manage Flavors in different files

productFlavors {
free {
buildConfigField "String", "TIMEOUT", "15"
paid {
buildConfigField "String", "TIMEOUT", "15"
productFlavors.all {
flavor ->
def fileName = + ".gradle"
if(file(fileName).exists()) {
apply from: fileName
initFlavor(flavor, project)
def localDefineValue = '"UAT localDefineValue"'
ext.initFlavor = {
it, project ->
it.applicationIdSuffix ".uat"
it.buildConfigField "String", "env", "\"UAT\""
it.resValue "string", "resValue", "Res UAT"
it.resValue("string", "resFunction", "Res UAT")

Properties properties = new Properties()
properties.load(project.rootProject.file('').newDataInputStream()) // load
def localPropertiesValue = properties.getProperty('localPropertiesValue', '')
it.buildConfigField "String", "localPropertiesValue", localPropertiesValue

it.buildConfigField "String", "gradlePropertiesValue", "${gradlePropertiesValue}"
it.buildConfigField "String", "localDefineValue", localDefineValue



Team lead of enterprise company, focus on mobile native and react native

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store