I need to create a demo flavor in android studio for an app. In my app level gradle file i have created another flavor called demo and the default flavor of full of course.
I was able to override classes but the key was not to include the class in my main folder.
So the fullDebug (i.e. main folder) build variant will never get run. Always run a flavor and not the main folder. The main folder will just be used to keep common things in it.
In my case I had a demo for USA and another country (demo and demo_us)and I needed two flavors. I'll always build for either of the two and won't build main.
From the image you can see I made all my package names to be the same: like com.example.******.myapplication
. Since they all have the same package name in the MainActivity
you just import Hello.java
with that package name and it will pick the right variant at build time.
For resources it looks like it's different and it will override naturally but java class files have to do this way.