My project structure look like below
+ src
+ main // this is my common code
+ java
- LoginScreen // depending on condition launch screen from flavor1 or flavor2
+ res
+ flavor1
+ java
+ res
+ flavor2
+ java
+ res
I have Login class in main/src depending on condition, have to launch the screen from flavor1 or flavor2.
For example:
class LoginScreen{
......
if(true){
// launch ScreenUser from Flavor1 reset of screen flows from falvour1
}else{
// launch ScreenOTP from Flavor2 reset of screen flows from falvour2
}
}
In this case, if I make build for flavor1 it is showing an error for falvor2 class and vice versa.
Both flavors has different applicationId like applicationIdSuffix ".flavor1"
Is this possible? If not how can I achieve this?
One of the possibilities to do that, if you want to have only one class with the
if
that check your buildType/productFlavor - you can set the value ofBuildConfig
field in both buildTypes/productFlavors by adding:And then you can use it in the code:
Hope, I've helped. Good luck!