无法解决:com.android.databinding:library:3.1.2

Kan*_*han 7 android android-gradle-plugin

更新android studio 3.1.2后,我现有的项目给出错误

dataBinding.enabled = true
Run Code Online (Sandbox Code Playgroud)

错误如下 -

Failed to resolve: com.android.databinding:library:3.1.2
Failed to resolve: com.android.databinding:adapters:3.1.2
Run Code Online (Sandbox Code Playgroud)

我的gradle依赖如下 -

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.1.0'

implementation 'com.android.support:recyclerview-v7:25.1.0'
implementation 'com.android.support:preference-v7:25.1.0'

implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta3'

implementation 'com.firebase:firebase-jobdispatcher:0.5.0'

// Instrumentation dependencies use androidTestCompile
// (as opposed to testCompile for local unit tests run in the JVM)
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:25.1.0'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test:rules:0.5'
Run Code Online (Sandbox Code Playgroud)

}

我也试过了

android.databinding.enableV2=true
Run Code Online (Sandbox Code Playgroud)

但它也没有用

当我尝试将构建工具版本更新到4.4时,我发现了这个错误.如果我不更新构建工具版本,那么它的工作正常.

And*_*eam 22

在项目级gradle文件中检查以下代码.

buildscript {

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they    belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

  • 在allprojects的存储库标签中添加google()对我有用.我想它无法下载绑定库,因为它是谷歌maven存储库的一部分. (7认同)

Far*_*ABZ 6

根据Android Team的答案你必须添加

谷歌()也是所有的存储库

优先权很重要.所以必须在google()之后添加其他存储库