gpt4 book ai didi

安卓 Kotlin : Error Unresolved reference: DaggerAppComponent

转载 作者:IT老高 更新时间:2023-10-28 13:29:28 31 4
gpt4 key购买 nike

我今天已经使用 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"

关于安卓 Kotlin : Error Unresolved reference: DaggerAppComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42843996/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com