How to handle theme colors depend on flavor in separate module?

I have project divided to few modules like below:

APP module (main module, contains user login process where user permission is downloaded)

|

v

Core module (code used by both modules A and B, for example utils related to saving files on disk)

|

v

-> Module A

-> Module B

Everything was fine until a new requirement came that the application must support two or more flavors.
I added flavors to build.gradle(app) with no problems. When switching build variants, colors.xml, layouts etc switched very well. I added this code.

productFlavors {
        hehe {
            applicationId "com.lol.hehe"
            buildConfigField "String", "FLAVOR_NAME", ""hehe""
            resValue "string", "app_name", "hehe"
        }

        hahaha {
            applicationId "com.lol.hahaha"
            buildConfigField "String", "FLAVOR_NAME", ""hahaha""
            resValue "string", "app_name", "hahaha"
        }
    }

Flavor "hehe" is for users to use only Module A, flavor "hahaha" is for users that use Module A and B.

My question is how to do it for Module B? I have no idea what is proper approach to do that.
Please help me to get to the right solution. Thanks for any suggestions!

Source: Android Questions

LEAVE A COMMENT