本文介绍了匕首2:@ Component.Builder缺少所需模块或组件的设置器:[appi.example.com.dagger.AppModule]`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在配置新的Dagger Android模块,但出现此错误这是我的组件:
I'm configuring the new Dagger Android module but I got this errorHere's my Component:
@AppScope
@Component(modules = {AppModule.class, NetModule.class})
public interface AppComponent {
@Component.Builder
interface Builder {
@BindsInstance
Builder application(ExampleApplication application);
@BindsInstance
Builder appModule(AppModule appModule);
@BindsInstance
Builder netModule(NetModule netModule);
AppComponent build();
}
void inject(ExampleApplication __);
...
我在应用程序中这样构建的
Which I build like this in my Application
appComponent = DaggerAppComponent
.builder()
.application(this)
.appModule(new AppModule(this))
.netModule(new NetModule())
.build()
.inject(this);
但是我仍然收到错误消息
But I still receive the error
错误:(20,3)错误:@ Component.Builder缺少所需模块或组件的设置器:[app.example.com.dagger.AppModule]
根据应该正确的文档,我缺少什么?
According to the documentation that should be right, What am I missing?
例如,这可能是带有构建器的有效组件:
For example, this could be a valid Component with a Builder:
@Component(modules = {BackendModule.class, FrontendModule.class})
interface MyComponent {
MyWidget myWidget();
@Component.Builder
interface Builder {
MyComponent build();
Builder backendModule(BackendModule bm);
Builder frontendModule(FrontendModule fm);
}
}
推荐答案
从AppModule.class中删除以下代码并重建项目
Remove the below code from the AppModule.class and rebuild the project
@Provides
@Singleton
Application provideContext(SomeApplication application) {
return application;
}
这篇关于匕首2:@ Component.Builder缺少所需模块或组件的设置器:[appi.example.com.dagger.AppModule]`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!