I am familiar with basics of flavors and dimensions, but not sure how to solve my problem.
Let's say I have 2 flavors in my app - GREEN and RED. They share common kotlin code and only differ in the look = they have their own resources folders with different colors and layouts.
Now I want to create something like a subflavor from GREEN - let's say GREEN_NOMENU, where the only difference against GREEN will be be disabling some menu items. 1-2 lines of code. Everything else is the same.
How to do this?
Creating a new flavor GREEN_NOMENU feels wrong, because that would also require copying all the resources from GREEN. I don't really like this, seems like a lot of duplicated files for 1 line of change in disabling some menu item.
Is it possible to create a flavor, which will inherit everything from another flavor?
What's a proper way to manage minimal changes in between variants/flavors like this?
You can create multiple flavor dimensions and combine them. See the docs here.
You could create another flavor
menuandnomenuand assign themenutypedimension to it.This would allow you to build your app with the version
greenMenu,greenNomenu,redMenuandredNomenu.You can then also create subfolders for your code and resources with the combined flavors. For example, you can create a resource folder specifically for
greenNomenuwhere you remove the menu items.