Search code examples
androidandroid-gradle-pluginandroid-productflavors

In Android flavors Activity not getting changed based on flavor. Only main package activity is called


I have created 2 flavors(one and two) and one main package as you can see in image which i have shared. These three flavors has a separate three MainActivity.class. when i change the flavor i am trying to change the textView content from MainActivity.class of its flavor, but it's not getting changed. Only the layout is getting replaced as per the flavor not the class.

For example, i set current flavor as one and set textView content as "one" from MainActivity.class its not getting changed but it takes the MainActivity.class of main package and the layout is working taken based on the flavor.

project structure image

enter image description here


Solution

  • Only the layout is getting replaced as per the flavor not the class.

    Because the MainActivity.java of "main" is used every time.

    The package name must be same in the other two modules.

    Java files are not replaced so, you can remove MainActivity of "main".