I have a number of flavors in my app, and I want to set a boolean buildConfigField for a subset of them. Is there a way to avoid having to add the field to every flavor? Ideally my build.gradle would look like the following:
productFlavors {     flavor1 {     }      ....      flavor4 {         buildConfigField "boolean", "DISABLE_SOMETHING", "true"     }      flavor5 {         buildConfigField "boolean", "DISABLE_SOMETHING", "true"     }      ....      flavor8 {     } } So in my app I can just go
if (BuildConfig.DISABLE_SOMETHING) {     //disable stuff } However, compilation fails when I try to build with, for example, flavor1, as it can't find the field. I don't want to have to remember to add this to every new flavor I create. Are there any ways around this?
You can use defaultConfig for this (inside android{})
defaultConfig {   buildConfigField "boolean", "DISABLE_SOMETHING", "true" } 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