Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 651
WorieN Avatar asked Oct 31 '17 09:10

WorieN


People also ask

How do I change a variant in build?

NOTE: By default, the Android Studio will generate "debug" and "release" Build Types for your project. So, to change a Build Type, all you need to do is just select your Build Type from the Build Variant and after the project sync, you are good to go.

How do I change my active build variant?

Change the build variant By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run. To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

When would you use product flavor in your build setup?

You use same core ingredients to make the base but will use different toppings for each one to have a different taste. Similarly, android apps can have the same base functionalities with changes to some of the features like styles, logo etc. This can be achieved using product flavours.

What is build flavor in Android?

Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs. Let's assign two product flavors free and paid in our application.


1 Answers

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

like image 67
Leandro Ocampo Avatar answered Oct 16 '22 05:10

Leandro Ocampo