Group Group Group Group Group Group Group Group Group

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")
    }
}


flavorDimensions("version")
productFlavors {
    create("flavor1") {
        setDimension("version")
    }
    create("flavor2") {
        setDimension("version")
        versionCode = 1
        versionName = "1.0"
    }
}