找不到com.android.databinding:library:3.1.1

时间:2018-04-13 10:00:58

标签: android android-studio android-gradle android-databinding

我已升级到Android Studio 3.1.1并尝试从GitHub克隆项目但由于以下错误无法运行该项目

Could not find com.android.databinding:library:3.1.1.

我试过this& this但无法解决问题。后者建议更新到3.2 canary 10版本,但是3.1.1无法解决这个问题吗?

在Android小组建议后编辑

buildscript {
    repositories {
        jcenter()
      google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

截图: enter image description here

2 个答案:

答案 0 :(得分:4)

您可以添加项目级gradle文件,请确认您的gradle文件中没有遗漏 jcenter()

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
}

答案 1 :(得分:1)

只需将google()添加到您的项目级gradle文件中,它将解决此问题

buildscript {
repositories {
    google()        //<-----This line
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.1'
    classpath 'com.google.gms:google-services:4.0.1'

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

allprojects {
    repositories {
        google()     //<-----This line
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

}