Search code examples
androidgradlebuild-script

how to build different variants of android through gradle


I already have

2 flavours (staging, production)

2 buildTypes (debug, release)

beyond that, I want to have different variants for, say, different vendors. like a production-release build for samsung and htc. is it possible through build scripts?

PS: I don't want to use 3rd party plugin like this


Solution

  • You could use flavor dimensions.

    android {
        flavorDimensions 'environment', 'vendor'
    
        productFlavors {
            staging {
                flavorDimension 'environment'
            }
    
            production {
                flavorDimension 'environment'
            }
    
            htc {
                flavorDimension 'vendor'
            }
    
            samsung {
                flavorDimension 'vendor'
            }
        }
    }