问题
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?
回答1:
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"
}
来源:https://stackoverflow.com/questions/39088271/does-android-studio-support-sub-flavors