We can build multiple variants of application using product flavours field in build gradle. Why flavour dimension? And it is made compulsory with error message, "All flavours should now belong to flavour dimension"
If it has sensible uses, How and where can we differentiate configuration for different flavour dimensions?
All other blogs and posts I referred didn't give me satisfying answers and most tell me "you won't need it". Please throw some light.
I'd best describe flavour dimensions as a way of grouping flavours.
The one use case I can think of is this.
You have a free and paid flavour under a dimension of tier.
You have a test and prod flavour which point to different backends under a dimension of environment.
When you assemble all you end up with a version for each tier and environment so you can test a free/test version, free/prod version etc.
You don't need to inspect the dimension, just put whatever variables/ conditional code against the flavour as has always been the case.
An example using multiple dimensions
,,,
flavorDimensions "tier", "env"
productFlavors {
paid {
dimension "tier"
... add variables here
}
free {
dimension "tier"
versionName = android.defaultConfig.versionName + " free"
... add variables here
}
test {
dimension "env"
... add variables here
}
prod {
dimension "env"
... add variables here
}
}
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With