使用匕首时发出警告:“ @ Component.Builder具有不需要的模块或组件的设置器”

时间:2019-03-29 11:21:46

标签: android dagger-2

我正在尝试使用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

我们非常感谢您的帮助。

0 个答案:

没有答案