Android Kotlin:错误未解决参考:DaggerAppComponent

2024-01-08

我今天已使用 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 文件是自动生成的,所以我很困惑为什么会抛出未解析的引用错误。


apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'   

在你的依赖项中:

implementation "com.google.dagger:dagger:2.x"
implementation "com.google.dagger:dagger-android:2.x"
implementation "com.google.dagger:dagger-android-support:2.x"
kapt "com.google.dagger:dagger-compiler:2.x"
kapt "com.google.dagger:dagger-android-processor:2.x"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android Kotlin:错误未解决参考:DaggerAppComponent 的相关文章

随机推荐