1

I'm trying to apply the equivalent of Android's product flavor with a Java library. My project configuration can be resumed in:

  • App module (type: Android application)
  • Api calls module (type: Java library)

The app module only has one product flavor (the default one) and the api module will have several ones, one per environment (local, preproduction server and production server).

I've been checking some questions and I've found this one that achieves something similar to product flavors with only Java projects. There is also this other question that explains how to get android libraries with product flavors.

My question is: can an Android app module define a dependency on a Java library module defining the library configuration?

Should I refactor my architecture making the Android app module has several product flavors, in each one passing the configuration parameters to the Java library?

Community
  • 1
  • 1
Alberto S.
  • 7,409
  • 6
  • 27
  • 46
  • The second one; the module should have a few product flavors and pass the config parameters to the Java library based on it's flavor. – Shark Mar 01 '16 at 15:48
  • since you cannot decide at runtime which lib-favor to use you have to create an app flavor for every lib flavor and deploy the app-flavor which is linked to the "correct" lib. the app dependencies have to be flavor-specific. If you ask more specific (include the gradle files of lib and app) you will get a more specific answer – k3b Mar 01 '16 at 16:16
  • Are there any updates on this topic? I do not need all the android overhead for one of my modules. – Wout Jan 10 '18 at 11:15

0 Answers0