我正在尝试使用Dagger实现新功能。
我的代码
object File {
lateinit var component: Component
fun initialize(@NotNull context: Context) {
component = DaggerFile_Component
.builder()
.context(context)
.build()
}
@dagger.Component(modules = [Module::class])
interface Component {
fun uploadFile(): UploadFile
fun awsService(): AwsService
fun glideLoad(): GlideLoad
@dagger.Component.Builder
interface Builder {
@BindsInstance
fun context(context: Context): Builder
fun build(): Component
}
}
@dagger.Module
internal abstract class Module {
@Binds
internal abstract fun bindUploadFile(uploadFileImp: UploadFileImp): UploadFile
@Binds
internal abstract fun bindAwsService(awsServiceImp: AwsServiceImp): AwsService
@Binds
internal abstract fun bindGlideLoad(glideLoadImp: GlideLoadImp): GlideLoad
}
}
在构建项目时,我得到:
@Component.Builder has setters for modules or components that aren't required
我们非常感谢您的帮助。