Dagger 2: Cannot be provided without an @Provides-annotated method

Your CoffeeMachine needs CoffeeMaker. And you have declared that Dagger will take care of providing that dependency to the CoffeeMachine by annotating the constructor with @Inject. But Dagger says: CoffeeMaker cannot be provided without an @Provides-annotated method Because you haven’t specified anywhere how CoffeeMaker object should be created. @Injecting SimpleMaker is not enough, because SimpleMaker … Read more

Dagger 2 – two provides method that provide same interface

I recently post the answer to a question like this in this post : Dagger 2 : error while getting a multiple instances of same object with @Named You need to use @Named(“someName”)in your module like this: @Module public class ApplicationModule { private Shape rec; private Shape circle; public ApplicationModule() { rec = new Rectangle(); … Read more

Dagger 2 error: dependency “cannot be provided without an @Inject constructor” while it actually annotated with @Inject

I got this same error because I forgot to expose the objects provided by the modules in the parent component to the other components that are depend on it. Parent component example: @Singleton @Component(modules = {AppModule.class}) public interface AppComponent { AppPref exposeAppPref(); /* my issue was caused by forgot this line, the method name doesn’t … Read more

Can I just inject super class when use dagger2 for dependency injection?

I encountered the same situation. One way to ease a bit the injection from a common component in all Activities is the following: 1) Extend the Application class to be able to create the common component and keep a reference to it. public class ApplicationDagger extends Application { private ApplicationComponent component; @Override public void onCreate(){ … Read more