Dagger 2 error: cannot be provided without an @Inject constructor

Make sure the scope is different between the component and its subcomponent, or component and it’s parent component that’s declared using the dependencies.

Make sure the parent component expose the objects that you will be using in the component. In this dependencies example below, AppPref exposeAppPref(); is exposing the AppPref to it’s child components. The method name doesn’t matter, but the type of method has to be the type of the object you want to make it available to child components.
The component AppComponent.java

@Component(modules = {AppModule.class})
public interface AppComponent {
    AppPref exposeAppPref(); //make sure this is there

The child component ActivityComponent.java depending on the parent component AppComponent.java

@Component (dependencies = {AppComponent.class})
public interface ActivityComponent {
    void inject(MainActivity activity);

Search within Codexpedia

Custom Search

Search the entire web

Custom Search