在 Android Studio 3.0 Canary 4 中设置 dagger 2.x 时出现以下错误
错误:(71, 20) 无法解析:com.google.dagger:dagger:2.x
错误:(73, 20) 解析失败:com.google.dagger:dagger-android:2.x
错误:(74, 20) 无法解决:com.google.dagger:dagger-android-support:2.x
我的构建文件如下:
dependencies {
//For DI - Dagger 2
implementation 'com.google.dagger:dagger:2.x'
annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
implementation 'com.google.dagger:dagger-android:2.x' // If you're using classes in dagger.android
implementation 'com.google.dagger:dagger-android-support:2.x' // if you use the support libraries
annotationProcessor 'com.google.dagger:dagger-android-processor:2.x'
}
项目构建文件有以下 fragment
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
感谢您的帮助...
最佳答案
如果你和我一样陷入这个问题,这就是我为摆脱这种情况所做的。
我去了https://github.com/google/dagger/releases找出dagger的最新发布版本,发现v2.11是最新的。我在构建文件中的此库配置的版本部分中将 2.x 替换为 2.11,并且构建成功。
dependencies {
//For DI - Dagger 2
implementation 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
implementation 'com.google.dagger:dagger-android:2.11' // If you're using classes in dagger.android
implementation 'com.google.dagger:dagger-android-support:2.11' // if you use the support libraries
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
}
关于android - 问题在 AndroidStudio3.0 Canary4 上为 Android 设置 Dagger 2.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44749287/