android-gradle Configure Product Flavors Flavor Constants and Resources in build.gradle


You can use gradle to have BuildConfig constants and res values on a per flavor basis. Just add the value to the flavor you want to support.

android {
    defaultConfig {
        resValue "string", "app_name", "Full App"
        buildConfigField "boolean", "isDemo", "false"
    productFlavors {
        demo {
            resValue "String", "app_name", "Demo App"
            buildConfigField "boolean", "isDemo", "true"
        full {
            // use default values

Gradle will do all the merging / overriding for you. The generated code will also allow you to see where the values come from, e.g.

<!-- Values from default config. -->
<string name="app_name" translatable="false">Default Name</string>


public final class BuildConfig {
    public static final String VERSION_NAME = "1.0";
    // Fields from product flavor: demo
    public static final boolean isDemo = true;