我使用匕首柄制作一个项目,当我制作动态功能时,它会显示这样的错误
/MyApplication_HiltComponents.java:166: error: [Dagger/MissingBinding] com.apps.jobwishlist3.core.domain.usecase.JobUseCase cannot be provided without an @Provides-annotated method.
public abstract static class ApplicationC implements MyApplication_GeneratedInjector,
^
A binding with matching key exists in component: com.apps.jobwishlist3.MyApplication_HiltComponents.ActivityC
com.apps.jobwishlist3.core.domain.usecase.JobUseCase is requested at
com.apps.jobwishlist3.di.FullTimeModuleDependencies.jobUseCase()
我真的不知道这个错误意味着什么。我尝试删除@singeton,但仍然出现该错误。
我已经像这段代码一样制作了匕首柄所需的一切
@EntryPoint
@InstallIn(ApplicationComponent::class)
interface FullTimeModuleDependencies {
fun jobUseCase(): JobUseCase
}
还有这个
@Component(dependencies = [FullTimeModuleDependencies::class])
interface FullTimeComponent {
fun inject(activity: FullTimeActivity)
@Component.Builder
interface Builder {
fun context(@BindsInstance context: Context): Builder
fun appDependencies(fullTimeModuleDependencies: FullTimeModuleDependencies): Builder
fun build(): FullTimeComponent
}
}
但匕首仍然没有在我的此活动代码中生成它
DaggerFullTimeComponent.builder()
.context(this)
.appDependencies(
EntryPointAccessors.fromApplication(
applicationContext,
FullTimeModuleDependencies::class.java
)
)
.build()
.inject(this)
DaggerFullTimeComponent
仍然是红色的,我不知道该怎么办。如果有人知道请帮忙。谢谢你。
如果您需要了解全部内容,这是我的完整项目:https://github.com/cube76/JobWishlist3
从你的项目来看,
JobUseCase
是接口,dagger不知道如何提供他。也许您必须将 JobUseCase
的实现添加到任何 dagger 模块中。
@Binds
fun bindJobUseCase(interactor: JobInteractor): JobUseCase