【发布时间】:2016-12-14 11:12:22
【问题描述】:
我正在尝试创建我的应用组件,但 Dagger 没有生成我的应用组件。 这是 MyApplication 类
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
上的 project这是错误日志
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
【问题讨论】:
-
当您尝试构建应用程序时它会说什么?
-
我已经更新了我的问题
-
@user5543258 你的问题解决了吗?我也有同样的问题。
-
这里没有工作,你找到解决方案了吗?