Skip to content

Instantly share code, notes, and snippets.

@fabiendevos
Last active October 26, 2015 20:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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