我使用的是 dagger 2.24,没有 dagger-android。我的组件设置如下:
@Singleton
@Component(modules = [
FirebaseModule::class,
ViewModelFactoryModule::class,
DispatcherModule::class,
NetworkModule::class
])
interface AppComponent {
fun getSignInComponent(): SignInComponent
fun getMapComponent(): MapComponent
// some other subcomponent creation methods
fun getNewMeetingComponent(): NewMeetingComponent // THIS method is not implemented by DaggerAppComponent
@Component.Factory
interface Factory {
fun create(
@BindsInstance context: Context
// some other dependencies
): AppComponent
}
}
/////////////////////////////////////////////////////////////////////
@ViewScope
@Subcomponent(modules = [NewMeetingModule::class])
interface NewMeetingComponent {
fun inject(newMeetingActivity: NewMeetingActivity)
}
发生的情况是 dagger 生成所有子组件创建方法,如下所示:
@Override
public SignInComponent getSignInComponent() {
return new SignInComponentImpl();
}
但根本不生成任何实现fun getNewMeetingComponent(): NewMeetingComponent。这确实很奇怪,因为其他子组件之间没有概念上的差异。
构建失败并显示一条简单消息
DaggerAppComponent is not abstract and does not override abstract method getNewMeetingComponent() in AppComponent
PIPIONE
慕容708150
相关分类