'Defining dimensions in Kotlin DSL for gradle
I'm converting my build.gradle to Kotlin DSL. I have 2 build flavors in the app, and I can't figure out how to set the dimension for the flavors:
flavorDimensions("type")
productFlavors {
create("free") {
buildConfigField("boolean", "IS_DONATE", false.toString())
dimension = "type"
}
create("donate") {
buildConfigField("boolean", "IS_DONATE", true.toString())
dimension = "type"
}
}
the dimension = "type" part is failing; how do you set the dimension to each flavor?
Solution 1:[1]
As an addition to the answer of Shweta Chauhan, in new versions of Gradle, setDimension("type") is deprecated.
You should use dimension("type") instead.
Solution 2:[2]
If you are using a newer gradle version with kotlin script:
flavorDimensions.add("type")
productFlavors {
create("free") {
dimension = "type"
buildConfigField(...)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | enoler |
| Solution 2 | Javatar |
