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

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
WorieN
  • 1,276
  • 1
  • 11
  • 30
  • Obviously because your flavors has different dimensions – Selvin Oct 31 '17 at 09:34
  • Possible duplicate of [Android Studio 3.0 Flavor Dimension Issue](https://stackoverflow.com/questions/44105127/android-studio-3-0-flavor-dimension-issue) – Nawrez Oct 31 '17 at 09:36
  • No, it is not.. He doesn't get any error. If I understand his properly he wants to get productionapiDebug, germanapiDebug, and so on.... – Selvin Oct 31 '17 at 09:39
  • Selvin, so I need the same dimension for different variants? – WorieN Oct 31 '17 at 09:53

1 Answers1

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

Leandro Ocampo
  • 1,894
  • 18
  • 38
  • 4
    Yes, you are right. But, also you need to add flavorDimensions "default" to build it successfully. If don't - it won't compile – WorieN Oct 31 '17 at 13:28
  • @WorieN : I have the same issue, how do you fix the issue finally? Can you post the gradle script that fixed your issue? – Moussa Nov 22 '17 at 09:49
  • @Mouss the gradle script is in my answer but as he said, you need to add flavorDimensions "default" also! – Leandro Ocampo Nov 22 '17 at 13:01
  • @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 :) – Moussa Nov 22 '17 at 13:58
  • @LeandroOcampo : thanx a lot! – Moussa Nov 22 '17 at 14:19