I'm trying to learn Dependency Injection using Dagger.
I understand that in your classes, you won't directly instantiate the object your client code depends on, but declare it with @Inject, create a ObjectGraphs via a Module, and get the object from the ObjectGraph:
@Inject CoffeeMaker coffeeMaker;
public static void main(String[] args) {
ObjectGraph objectGraph = ObjectGraph.create(new DripCoffeeModule());
CoffeeApp coffeeApp = objectGraph.get(CoffeeApp.class);
....
}
However, all that code depends now on the Module that you are using to create the ObjectGraph (DripCoffeeModule, in this example).
Now I want to use this in my Android app. For the debug build I want a specific implementation of my classes, for the release build the implementation will be different.
How am I supposed to do that? How can I set up the build.xml ant script to make that the Module supplies the specific implementations that I want? (or to choose the correct Module)...
Thank you.