简体   繁体   中英

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

I upgraded to Android Studio 3.1.1 and trying to clone a project from GitHub but unable to run it due to the following error

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

I have tried this & this but unable to resolve the issue. The latter suggests to update to the 3.2 canary 10 version but is there no way to resolve this in 3.1.1?

EDIT after Android Team suggestion

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
}

Screenshot: 在此输入图像描述

you can add your project level gradle file ,please verify you are not missing jcenter() in your gradle file

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
}

just add google() to your project level gradle file, and it will fix the issue

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
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM