I'm setting up the product flavors in my app and have run into one problem. Two of my product flavors are very similar to each other and only differ by a few resources, let's call them FlavorA and FlavorB. I would like to set it up so that FlavorA is the parent of FlavorB, that way FlavorB can just override a few resources of FlavorA, and then FlavorA overrides a bunch of resources from main. Is there a way to set up a flavor hierarchy such as this? Right now I need to duplicate lots of resources between the two in order for it to work and I would like to eliminate that duplication.
edit: OK. I've had a couple answers so far (both deleted) that were not related to my question so let me clarify. This does not have to do with Java OOP, I already know that quite well. :)
The issue I'm having is that I have a free/paid version of my app, and then several white labels that only include theme changes. The paid version only changes a few assets from the free version (apart from code changes). This is what my productFlavors
look like:
productFlavors {
whiteLabelA {
applicationId "com.whiteLabelA.android"
}
whiteLabelB {
applicationId "com.whiteLabelB.android"
}
mainFree {
applicationId "com.mainFree.android"
}
mainPaid {
applicationId "com.mainFree.android.paid"
}
}
I would like mainPaid
to override mainFree
since it only changes a few resources. I would like to do it this way rather than a free/paid build type because the white labels don't have paid versions, and it would be easier to have a flavor hierarchy like:
mainPaid extends mainFree {
applicationId "com.mainFree.android.paid"
}