Last active
October 26, 2015 20:36
-
-
Save fabiendevos/d70db37904637906b2b3 to your computer and use it in GitHub Desktop.
Generating constants for all flavors (type-safe, unlike using a string)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
... | |
productFlavors.all { flavor -> | |
defaultConfig { | |
buildConfigField "String", "FLAVOR_" + flavor.name.toUpperCase(), "\"${flavor.name}\"" | |
} | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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