Skip to content

Instantly share code, notes, and snippets.

@fabiendevos
Last active October 26, 2015 20:36
Show Gist options
  • Save fabiendevos/d70db37904637906b2b3 to your computer and use it in GitHub Desktop.
Save fabiendevos/d70db37904637906b2b3 to your computer and use it in GitHub Desktop.
Generating constants for all flavors (type-safe, unlike using a string)
android {
...
productFlavors.all { flavor ->
defaultConfig {
buildConfigField "String", "FLAVOR_" + flavor.name.toUpperCase(), "\"${flavor.name}\""
}
}
...
}
if (BuildConfig.FLAVOR.equals(BuildConfig.FLAVOR_YOURFLAVOR)) {
// do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment