Android studio 3.0 build variants does not match flavors
Asked Answered
C

1

6

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

Cornish answered 31/10, 2017 at 9:14 Comment(4)
Obviously because your flavors has different dimensionsIntensive
Possible duplicate of Android Studio 3.0 Flavor Dimension IssueShoddy
No, it is not.. He doesn't get any error. If I understand his properly he wants to get productionapiDebug, germanapiDebug, and so on....Intensive
Selvin, so I need the same dimension for different variants?Cornish
F
6

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

Flanch answered 31/10, 2017 at 12:52 Comment(5)
Yes, you are right. But, also you need to add flavorDimensions "default" to build it successfully. If don't - it won't compileCornish
@Cornish : I have the same issue, how do you fix the issue finally? Can you post the gradle script that fixed your issue?Eileneeilis
@Mouss the gradle script is in my answer but as he said, you need to add flavorDimensions "default" also!Flanch
@LeandroOcampo : would it be possible please to add it directly to your post? When we are on stackoverflow, we often look only at post and not messages under the post... Thanx a lot :)Eileneeilis
@LeandroOcampo : thanx a lot!Eileneeilis

© 2022 - 2024 — McMap. All rights reserved.