I have an Android Studio project that currently has 2 product flavors in the build.gradle as follows:
productFlavors {
parent {
applicationId "xxx.parent"
}
teacher {
applicationId "xxx.teacher"
}
}
Both flavors have some common code under src/main
What I need is 1 more level of flavors, so I want under one flavor to have sub flavors which is 1 more level of customization (for some resources & some static variables)
So I want something similar to below:
productFlavors {
parent {
p1 {
applicationId "xxx.parent.p1"
}
p2 {
applicationId "xxx.parent.p2"
}
}
teacher {
t1 {
applicationId "xxx.teacher.t1"
}
t2 {
applicationId "xxx.teacher.t2"
}
}
}
So my aim is to have 2 types of applications (teacher & parent) and each can be customized n times (they will differ by application id, resource files & static variables)
Any idea how can this be achieved?
Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs.
To do this, the Android plugin for Gradle allows you to create multiple groups of product flavors as flavor dimensions. When building your app, Gradle combines a product flavor configuration from each flavor dimension you define, along with a build type configuration, to create the final build variant.
So minifyEnabled removes dead code but does not obfuscate or optimize.
Yes Gradle supports sub flavors - flavorDimensions. E.g.:
flavorDimensions "server", "lib"
productFlavors {
pub {
dimension "server"
minSdkVersion 19
resValue "string", "app_version_name", mVersionName
}
beta {
dimension "server"
minSdkVersion 9
resValue "string", "app_version_name", mVersionName + "beta"
}
xwalk {
dimension "lib"
}
webkit {
dimension "lib"
}
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