Search code examples
androidandroid-studiogradleandroid-productflavorsandroid-studio-3.0

Android studio 3.0 build variants does not match flavors


I'm trying to setup different build variants for Android Studio 3.0 and gradle plugin 3.0, but Android Studio doesn't create build variant for each my flavor. Gradle build is successfull but I don't know how to make productionapiRealese and germanyapiRelease build variants. How can I make it?

My flavors:

flavorDimensions "pr", "ger"
productFlavors {
    productionapi {

        provider "pk"
        dimension "pr"

    }
    germanyapi {
        provider "sd"
        dimension "ger"
    }
}

And my build variants:

enter image description here


Solution

  • First of all read this article in detail.

    As far as I understand you are mixing flavors using the information you can find in this section "Combine multiple product flavors with flavor dimensions".

    Just remove this:

    flavorDimensions "pr", "ger"
    

    and this from each flavor:

    dimension "ger"
    dimension "pr"
    

    Just focus on the first part of the section "Configure Product Flavors":

    android {
        ...
        defaultConfig {...}
        buildTypes {...}
        flavorDimensions "default"
        productFlavors {
            productionapi {
                applicationIdSuffix ".prod"
                versionNameSuffix "-prod"
            }
            germanyapi {
                applicationIdSuffix ".german"
                versionNameSuffix "-german"
            }
        }
    }
    

    Doing that you will get a build variant for each flavor