سؤال

I'm trying to integrate Dagger into my application. And I ran into a problem. I'm getting this error at runtime:

java.lang.IllegalStateException: Errors creating object graph:
    com.app.NavigationController has no injectable members. Do you want to add an injectable constructor? required by class com.app.fragments.LoginFragment

I tried looking into other, similar answers, but nothing helped me so far...

Everything related to graph construction is implemented pretty much like in Android Activity Graphs example.

I have two modules ActivityModule and ApplicationModule.

@Module(
        includes = ApplicationModule.class,
        injects = {
                MainActivity.class,
                LoginFragment.class
        }
)
public class ActivityModule {

    private BaseActivity activity;

    public ActivityModule(BaseActivity activity) {
        this.activity = activity;
    }

    @Provides
    @Singleton
    NavigationController provideNavigation() {
        return new NavigationController(activity);
    }
}

And another

@Module(
    injects = {
            MainActivity.class,
            LoginFragment.class},
    complete = false
)
public class ApplicationModule {

    private Context context;

    public ApplicationModule(Context context) {
        this.context = context;
    }

    @Provides
    @Singleton
    ApiService provideApiService() {
        ....
        return restAdapter.create(ApiService.class);
    }
}

What am I doing wrong?

UPDATE:
Adding more details:

Fragment:

public class LoginFragment extends BaseFragment {

    //...

    @Inject
    NavigationController navigation;

    //...

Navigation controller:

public class NavigationController {

//...

public NavigationController(BaseActivity activity) {
    this.activity = activity;
}

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

المحلول

Question was answered in this Dagger GitHub issue #372

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