In my android application, I have 2 library modules that need to be included conditionally based on flavor. Following is the application structure
:app
:library1
:library2
And app has 2 flavors, so it will generate 2 apk's, one free version and another paid. So accordingly configured app build.gradle as follows:
android {
flavorDimensions("billing_type")
productFlavors {
free {
dimension "billing_type"
}
paid {
dimension "billing_type"
}
}
}
dependencies {
implementation project(path: 'flavor1')
implementation project(path: 'flavor2')
}
As we can see, both library modules will be included in both flavors(free and paid). But i want to include library2 only in paid flavor. So how can i conditionally add library2 only in paid flavor? I followed some of the approaches mentioned in link
and made following changes:
android {
flavorDimensions("billing_type")
productFlavors {
free {
dimension "billing_type"
}
paid {
dimension "billing_type"
}
}
}
configurations {
freeImplementation
paidImplementation
}
dependencies {
freeImplementation implementation project(path: 'flavor1')
paidImplementation implementation project(path: 'flavor2')
}
All the references online are for older grdale versions which uses compile to add library modules, But it has been deprecated since gradle plugin 3.0.0. So can anyone help me figure out how to conditionally add library module in particular flavor only in latest