未解决的参考DaggerApplicationComponent [英] Unresolved reference DaggerApplicationComponent

查看:224
本文介绍了未解决的参考DaggerApplicationComponent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建我的应用程序组件,但是Dagger不会生成我的应用程序组件. 这是 MyApplication

I'm trying to create my app component, but Dagger does not generate my app component. here is MyApplication class

class MyApplication : Application() {

companion object {
    @JvmStatic lateinit var graph: ApplicationComponent
}
@Inject
lateinit var locationManager : LocationManager

override fun onCreate() {
    super.onCreate()
    graph = DaggerApplicationComponent.builder().appModule(AppModule(this)).build()
    graph.inject(this)
  }
}

这是我的 AppComponent

@Singleton
@Component(modules = arrayOf(AppModule::class))
interface ApplicationComponent {
    fun inject(application: MyApplication)
}

这是屏幕截图

这是我在 github

这是错误日志

Error:(7, 48) Unresolved reference: DaggerApplicationComponent
Error:(28, 17) Unresolved reference: DaggerApplicationComponent
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
Information:BUILD FAILED
Information:Total time: 21.184 secs
Error:e: .../MyApplication.kt: (7, 48): Unresolved reference: DaggerApplicationComponent
e: Unresolved reference: DaggerApplicationComponent
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Information:4 errors
Information:0 warnings
Information:See complete output in console

推荐答案

我的解决方案是添加

apply plugin: 'kotlin-kapt'

然后删除

kapt {
    generateStubs = true
}

这篇关于未解决的参考DaggerApplicationComponent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆