Product flavor wise module implementation

71 Views Asked by At

I have 2 local modules, say cat and dog. Both have their platform specific code. Corresponding to these, there are two product flavors as well, say catFlav and dogFlav. The app module's build.gradle file looks something like this:

productFlavors {
    catFlav {
        applicationIdSuffix ".cat"
    }
    dogFlav {
        applicationIdSuffix ".dog"
    }
}

dependencies {
    catImplementation project(":platform:cat")
    dogImplementation project(":platform:dog")
    ...
}

In my app module, I have an interface called PlatformUtils. How can I have two files CatPlatformUtilsImpl and DogPlatformUtilsImpl in the respective modules, so that only the relevant file according to the flavor is picked? I'm using Koin for DI.

I've tried using the regular implementation instead of the flavor specific. It works fine, but I don't want to include modules from one flavor in another.

0

There are 0 best solutions below