White Labeling Android Apps: Getting Started | raywenderlich.com

In this tutorial, you’ll learn step by step how to white label your Android apps by using Android flavors and build variants.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5175277-white-labeling-android-apps-getting-started

I was trying to do white labeling for my app but I am stuck at a point where I need to use configuration based on buildType + flavor combination.

i.e let’s assume I have 2 buildTypes (debug & release) and 2 flavors (flavor1 & flavor2), I would like to use 4 different keys based on the combination as follows:

  1. flavor1 + debug = key1
  2. flavor1 + release = key2
  3. flavor2 + debug = key3
  4. flavor2 + release = key4

how do I achieve the same?

below is my build.gradle file.

buildTypes {
    getByName("debug") {
        applicationIdSuffix = ".debug"
        versionNameSuffix = ".debug"
        buildConfigField("boolean", "DEBUG_MODE", "true")

    getByName("release") {
        proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
        buildConfigField("boolean", "DEBUG_MODE", "false")

productFlavors {
    create("flavor1") {
    create("flavor2") {
        versionCode = 1
        versionName = "1.0"

@iaaqibhussain Can you please help with this when you get a chance? Thank you - much appreciated! :]


I don’t clearly understand your question that what you mean by keys. if that are some hardcoded keys you want to assign what you can do is update your gradle code to this:

    productFlavors {
       animaldom { ext {
            variable = [debug: "key-1", release: "key-2"]
        } }

    catsPlanet {
    dimension 'version'
        applicationId "com.raywenderlich.android.catsPlanet"

        ext {
            variable = [debug: "key-3", release: "key-4"]


Under it also add:

 applicationVariants.all { variant ->
    def flavor = variant.productFlavors[0]
    variant.buildConfigField "String", "KEY", "\"${flavor.variable[variant.buildType.name]}\""

Now to access those keys anywhere in your code.

BuildConfig.KEY //Depending on your flavor you will get your key here

Hope this helped. :]

Thank you!

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!