Use buildType in productFlavors or productFlavor in buildType

Hi,
i need build some version of app witch diferent version code by buildType AND product flavor.
example:
buildTypes are - debug, release, qa, beta
productFlavors are - flavor1, flavor2, flavor3,…

and i need for example set the versionCode for:

  • flavor1 AND beta = 1.2

  • flavor1 AND release = 1.1

  • flavor2 AND beta = 2.2

  • flavor2 AND release = 2.0
    that’s mean, i have for every combination other versionCode
    can i use builType in productFlavor, or productFlavor in buildType to do something this:

    buildType{
    release{
    if (productFlavor.name == “flavor1”) versionCode = 1.1
    if (productFlavor.name == “flavor2”) versionCode = 2.0
    }
    beta{
    if (productFlavor.name == “flavor1”) versionCode = 1.2
    if (productFlavor.name == “flavor2”) versionCode = 2.2
    }

    }

OR this

productFlavor{
   flavor1{
     if (buildType.name == "release") versionCode = 1.1
     if (buildType.name == "release") versionCode = 2.0
   }
   flavor2{
     if (buildType.name == "beta") versionCode = 1.2
     if (buildType.name == "beta") versionCode = 2.2
   }
   ...
}

or how can i set version codes for each combination?
Thanks

I think your only option is to use multiple AndroidManifest.xml files in the appropriate source directories for your variants. You’ll have to define the versionCode in the manifest rather than your build script and put the manifests in src/flavor1Beta and src/flavor1Release, etc.