I know that in buildTypes
I can declare, but I want to declare in productFlavors
.
like this:
productFlavors {
f1 {
some_variable: "v_f1"
}
f2 {
some_variable: "v_f2"
}
}
similar question :
Is it possible to declare a variable in Gradle usable in Java?
Yes, like this:
productFlavors {
f1 {
buildConfigField "boolean", "aBoolean", "true"
buildConfigField "String", "aString", "foo"
}
f2 {
buildConfigField "boolean", "aBoolean", "false"
buildConfigField "String", "aString", "bar"
}
}
then at runtime you can access them like:
if (BuildConfig.aBoolean) {
// do something
}