【发布时间】:2017-08-08 05:06:27
【问题描述】:
我今天已经使用 Dagger 2 将 Kotlin 插件安装到现有项目中。在安装 Kotlin 之前,我对 Dagger 没有任何问题。但是,现在编译器抱怨:
Error:(5, 32) Unresolved reference: DaggerAppComponent
Error:Execution failed for task ':app:compileDebugKotlinAfterJava'.
> Compilation error. See log for more details
Error:(12, 21) Unresolved reference: DaggerAppComponent
项目等级:
ext.kotlin_version = '1.1.1'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
模块分级:
kapt {
generateStubs = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.dagger:dagger:2.7'
kapt 'com.google.dagger:dagger-compiler:2.7'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
DaggerAppComponent 文件是自动生成的,所以我很困惑为什么会抛出未解析的引用错误。
【问题讨论】:
-
你解决了你的问题?出了什么问题?
-
打开
Gradle Console然后点击Run with --stacktrace显示更多日志(关于错误的更多细节)
标签: android android-studio kotlin dagger-2