build.gradleversioningandroid-productflavorsandroid-build-flavorsandroid-flavordimension

Android Studio - productFlavor combinations to set version


In my build.gradle, I'm defining 2 different flavor dimensions:

//list flavorDimensions in override priority order
flavorDimensions 'flavor', 'platform'

//assign each productFlavor a corresponding flavorDimension
productFlavors {
    flavor1 {
        dimension 'flavor'
        applicationId "com.flavor1"
    }
    flavor2 {
        dimension 'flavor'
        applicationId "com.flavor2"
    }
    mobile {
        dimension 'platform'
        applicationIdSuffix '.mobile'
        minSdkVersion 22
    }
    tv {
        dimension 'platform'
        applicationIdSuffix '.tv'
        minSdkVersion 21
    }
}

I would like to be able to set versionCode and versionName based on the combinations, so each of the following could have it's own version info:


Solution

  • Was able to build a solution by combining the solutions from :