Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dagger - class has no injectable members

Tags:

android

dagger

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;
}

//...
}
like image 729
Martynas Jurkus Avatar asked Jan 05 '14 10:01

Martynas Jurkus


1 Answers

Question was answered in this Dagger GitHub issue #372

like image 161
Martynas Jurkus Avatar answered Oct 24 '22 18:10

Martynas Jurkus