Inside build.gradle
we could
productFlavors {
free {
dimension "tier"
}
}
Then
dependencies { freeDebugImplementation "com.someDependency:free-debug:1.0.0";}
BUT when I use Kotlin DSL
, inside build.gradle.kts
, I
productFlavors { create("free") {...} }
Then in dependencies
I can not
dependencies { freeImplementation(...)}
Error: ^ Unresolved reference: freeImplementation
So, how can I implementation
for specific flavor via Kotlin DSL?
void missingDimensionStrategy ( String dimension, String requestedValue) Specifies a flavor that the plugin should try to use from a given dimension in a dependency. Android plugin 3.0. 0 and higher try to match each variant of your module with the same one from its dependencies.
Product Flavors so what are they? Simply put, a product flavor is a variant of your app. It is very useful when you want to create multiple versions of your app. This means you can generate different versions or variants of your app using a single codebase.
Flavor Dimensions is a way to group flavors by a name. For now, we're using just a single group. Add the following line in your defaultConfig block: flavorDimensions "default" Now syncing the gradle would give you the following product flavors: Android Build Variants combine build types and product flavors.
gradle. getStartParameter(). getTaskRequests(). toString() contains your current flavor name but the first character is capital.
I Kotlin DSL flavor specific dependency looks like this:
dependencies {
"freeImplementation"(...)
"paidImplementation"(...)
}
You should use the sample "YOUR_FLAVOR_NAMEimplementation"
dependencies {
"freeImplementation" "your dependency is here"
"paidImplementation" "your dependency is here"
// Other dependencies
}
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