سؤال

Anyone that liked dagger around maybe can hint me out since I am not getting it. So I followed the example of coffee maker and it works fine, but then I wanted t provide another dependency in this case a cofee maker:

@Module(injects = CoffeeApp.class)
class DripCoffeeModule {
    @Provides
    Heater provideHeater() {
        return new ElectricHeater();
    }

    @Provides
    Pump providePump(Thermosiphon pump) {
        return pump;
    }

    @Provides
    CoffeeMaker provideCoffeeMaker() {
        return new ExpensiveCoffeeMaker();
    }

}

It fails saying:

Graph validation failed: You have these unused @Provider methods: 1. com.sample.dagger.DripCoffeeModule.providePump() Set library=true in your module to disable this 
 check.

But it is being injected in the CofeeApp, can someone explained why this happened? and more important do you have any other good documentation about dagger beside the official docs, and the talk gave by Jesse Wilson?

Thanks

هل كانت مفيدة؟

المحلول

Instead of providing the Heater and Pump dependencies and allowing Dagger to construct the CoffeeMaker class, you're explicitly creating the CoffeeMaker class yourself, so the Pump provision remains unused.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top