Is it possible that a flavor is based on a other flavor?
For example build.gradle:
productFlavors {
flavor1 {
flavorBase "main"
}
flavor2 {
flavorBase "main"
}
flavor3 {
flavorBase "main"
}
flavor4 {
flavorBase "flavor3"
}
flavor5 {
flavorBase "flavor3"
}
}
I ran into the same issue and needed something like a base flavor and two inherited flavors from that.
The best solution I ended up with after a few hours of trying out a lot of things was:
Now define additional source sets for your child flavors
flavor4 {
res.srcDirs = ['src/flavor3/res', 'src/flavor4/res']
java.srcDirs = ['src/flavor3/java', 'src/flavor4/java']
resources.srcDirs = ['src/flavor3/java', 'src/flavor4/java']
}
flavor5 {
res.srcDirs = ['src/flavor3/res', 'src/flavor5/res']
java.srcDirs = ['src/flavor3/java', 'src/flavor5/java']
resources.srcDirs = ['src/flavor3/java', 'src/flavor5/java']
}
So in flavor3 (which is in that sense not a flavor but I keep the naming as it was) you can define common code and resources. The only downside is, that its not possible do have the same class in the base folder and in the child folders.