问题在AndroidStudio3.0 Canary4上为Android设置Dagger 2.x.

kar*_*iks 19 android build.gradle android-gradle-plugin dagger-2 android-studio-3.0

在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'
}
Run Code Online (Sandbox Code Playgroud)

项目构建文件具有以下片段

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助......

kar*_*iks 39

如果你像我一样遇到这个问题,这就是我为摆脱这种情况所做的.

我去了https://github.com/google/dagger/releases找出最新发布的dagger版本,发现v2.11是最新版本.我在构建文件中的库配置的版本部分中用2.11替换了2.x,并且构建成功了宾果游戏.

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'
}
Run Code Online (Sandbox Code Playgroud)


Piy*_*ena 13

我相信你现在已经解决了你的问题,虽然在尝试了很少的其他人和这个之后,我找到了一个可靠的解决方案,并将其发布用于帮助他人.而不是2.x使用2. +.

它为我解决了所有问题,不仅解决了上述问题,还确保提供最新版本的dagger 2.x.

它应该如下所示:

dependencies {
    implementation 'com.google.dagger:dagger:2.+'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.+'
    implementation 'com.google.dagger:dagger-android:2.+' // If you're using classes in dagger.android
    implementation 'com.google.dagger:dagger-android-support:2.+' // if you use the support libraries
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.+'
}
Run Code Online (Sandbox Code Playgroud)

谢谢!