I have an android app with 2 flavors: -flavor1 -flavor2
My directory tree is :
/src/main
/src/flavor1
/src/flavor2
main has the default source set. flavor1, and flavor2 directories have their own source set, that gradle gets automatically. If I add a resource file into a flavour directory it overrides it from main, and works fine.
However, if I add a java class into flavor2 to override another one from "main", (for example an activity that needs to be different in flavor2), it doesn't replace it and it says there's a duplicated class in my project. I only got this to work by deleting the class from "main" directory and adding it to all flavors folders.
Is there a way I can override java classes just like resource files ? why does this happen?