Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: com.android.databinding:library:3.1.2

After updating android studio 3.1.2 my existing project gives error at

dataBinding.enabled = true

error is as follows-

Failed to resolve: com.android.databinding:library:3.1.2
Failed to resolve: com.android.databinding:adapters:3.1.2

my gradle dependency are as follows-

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'

}

I also tried

android.databinding.enableV2=true

but its also not working

When I tried to update build tool version to 4.4 then I found this error. I f I do not update the build tool version then its working fine.

like image 643
Kanchan Avatar asked Apr 26 '18 11:04

Kanchan


3 Answers

check it this below code in your project level 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
}
like image 58
Android Team Avatar answered Oct 06 '22 00:10

Android Team


According to the Android Team answer you had to add

google() too all repositories

and priority is important. so other repositories must be added after google()

like image 32
FarshidABZ Avatar answered Oct 05 '22 23:10

FarshidABZ


Downgrade to 3.1.0 in project level build.gradle file, then rebuild the project.

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
}

I hope this helps

like image 40
Bukunmi Avatar answered Oct 05 '22 23:10

Bukunmi