Inclusion of dependence with dagger 2 in only one of the products

My application consists of two products: free and pro. I have an ApplicationModule that provides an object for advertising, but this object is required only for the free version, since the pro version has no dependency com.google.android.gms:play-services-ads:8.3.0 . How to structure my project in such a way that only if the free taste of the product is used, does ApplicationModule provide an object of declarations?

+1
java android dagger-2
source share
1 answer

Since you have two products, I assume that the classes of the free version are in the correct version structure, outside the "main" set of resources. and theyโ€™re supposed to have a different set of resources for the paid version.

So, initialize the dagger component inside the main set of sources, but the ApplicationModule is in every set of flavor sources. The module is a provider, therefore, if you want to change the dependencies that you can get by specifying different providers, although both sets of sources (paid, unpaid) will have the same ApplicationModule in each.

+1
source share

All Articles