我一直在尝试使用Dagger (v1.1.0)为我的Android应用程序设置活动图。尽管它编译得很好,但我得到了如下所示的错误(完整跟踪here):
No injectable members on com.f2prateek.couchpotato.ui.ActivityActionBarController. Do you want to add an injectable constructor? required by class com.f2prateek.couchpotato.ui.fragments.DetailedMovieGridFragment我会尽最大努力突出重要的部分,但如果我错过了什么,我的整个项目都在GitHub上。只需运行./gradlew clean assemble构建apk即可。
我的ActivityModule具有Dagger似乎找不到的provider方法。
@Provides @Singleton ActivityActionBarController provideActionBarTitleController() {
return new ActivityActionBarController(activity);
}这个模块肯定会被添加到我的BaseActivity中的applicationGraph (然后将其保存为activityGraph),并且BaseFragment会将自身注入到activityGraph中。
发布于 2013-10-28 05:11:31
Dagger使用注释处理器来编写代码。如果你的类没有注解,它就找不到它。确保您为每个类添加了注释。例如,如果你想注入一个成员,你必须使用@Inject。尽量确保您注入的所有类都列在@Module(inject=...)下面。尽量确保所有类都列在模块类中的某个位置。
https://stackoverflow.com/questions/19577676
复制相似问题