Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0
Solution 1
I had this problem and solved it by adding "jcenter" under allprojects.repositories in my top-level build.gradle (I had been using mavenCentral).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.databinding:dataBinder:1.0-rc1'
}
}
allprojects {
repositories {
mavenCentral()
jcenter() // <=== *** Adding this fixed it ***
}
}
Solution 2
I got errors when I sync build.gradle files.
Error:Failed to resolve: com.android.databinding:library:1.0-rc0
Error:Failed to resolve: com.android.databinding:adapters:1.0-rc0
And I finally found the solution.
dependencies {
// instead of the below pathes...
//classpath "com.android.tools.build:gradle:1.3.0-beta2"
//classpath "com.android.databinding:dataBinder:1.0-rc0"
// I used the following classpathes.... It works!
classpath "com.android.tools.build:gradle:1.3.+"
classpath "com.android.databinding:dataBinder:1.+"
}
Solution 3
By looking at your error Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0
you should try this instead,
classpath "com.android.databinding:dataBinder:1.0-rc1"
To use
DataBinding
follow all these steps.
- Update your
Android Studio
toAndroid Studio 1.3
version. -
To set up your
application
to usedata binding
, adddata binding
to the class path of yourtop-level
build.gradle
file, right below "android".dependencies { classpath "com.android.tools.build:gradle:1.3" classpath "com.android.databinding:dataBinder:1.0-rc1" }
-
Then make sure jcenter is in the repositories list for your projects in the top-level build.gradle file.
allprojects { repositories { jcenter() } }
-
In each module you want to use data binding, apply the plugin right after android plugin.
apply plugin: 'com.android.application' apply plugin: 'com.android.databinding'
Clean
andbuild
your app.
Complete code
top-level
build.gradle
file,
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3'
classpath "com.android.databinding:dataBinder:1.0-rc1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
module-level
build.gradle
file,
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.packagename"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
For more detail Data Binding Guide.
For Complete demo Data Binding Android
Solution 4
Make sure you have Android Studio 1.3 or higher
Your project build.gradle should look something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And your module build.gradle should look something like this:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.my.appId"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I had a problem where I was targeting M Preview so nothing worked. Once I changed the build tools to 22.0.1, and the targetSdkVersion to 22, everything worked.
Solution 5
I had the same issue and solved it by updating android sdk tools to 24.3.3.
Related videos on Youtube
![Juan Mendez](https://i.stack.imgur.com/6l6Ci.png?s=256&g=1)
Comments
-
Juan Mendez over 2 years
This is an old question which is irrelevant today. See Android developer's instruction. Applying Databinding to your projects is a lot easier now than four years ago.
As I am going over Android Data binding Guide from https://developer.android.com/tools/data-binding/guide.html. I have made sure I am running Android Studio 1.3 (canary version).
Following the guidelines, I get this error:
Gradle sync failed: could not find com.android.databinding:library:1.0-rc0
Has anyone else have the same problem? Thanks for your help.
App build.gradle
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0-beta1' classpath "com.android.databinding:dataBinder:1.0-rc0" } } allprojects { repositories { jcenter() } }
Module build.graddle
apply plugin: 'com.android.application' apply plugin: 'com.android.databinding' apply plugin: 'android-apt' def AAVersion = '3.3' def MyProject = 'com.commonsware.android.frw.filesdemo' buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' } } repositories { mavenCentral() } apt { arguments { androidManifestFile variant.outputs[0].processResources.manifestFile resourcePackageName "$MyProject" } } android { compileSdkVersion 22 buildToolsVersion "22" defaultConfig { applicationId "$MyProject" minSdkVersion 17 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions{ exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory' } dexOptions { preDexLibraries = false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile "com.squareup:otto:1.3.6" compile "commons-io:commons-io:+" compile 'com.fasterxml.jackson.jr:jackson-jr-all:2.5.0' compile 'com.astuetz:pagerslidingtabstrip:1.0.1' apt "org.androidannotations:androidannotations:$AAVersion" compile "org.androidannotations:androidannotations-api:$AAVersion" }
-
LukeWaggoner almost 9 yearsDid you ever figure this out? All my stuff was working, and now it's not. I've got gradle build 1.3.0-beta4, and com.android.databinding:library:1.0-rc0, with buildt tools version 23.0.0 rc3.
-
LukeWaggoner almost 9 yearsI just figured my issue out. Removing the android-apt plugin caused everything to resolve. Spent two days working on this. Hope this saves someone some time.
-
Mike6679 about 8 yearsMan I tried everything here, what else could be the problem??
-
-
Juan Mendez about 9 yearsVladimir, thanks a lot for your help. I had only upgraded Android Studio version and ignored the SDK. After a while upgrading, the error went away and following the changes you pointed out in my configuration files.
-
Yoel Gluschnaider about 9 yearsDid not work for me. It seems to be looking for this package in the SDK. I updated both the Android and Google repos in my SDK.
-
Yoel Gluschnaider about 9 yearsDid work, had a different issue. I work behind an SSL cert so I needed to set the allprojects scope with the http jcenter repo as well.
-
Juan Mendez about 9 yearsMake sure your build tools in SDK Manager is up to date as well. As I was working with other dependency injection, I found that my application wasn't able to get generated classed having Binding as suffix. I had to modify the gradle declarations for that to work, and hope that can help others who are trying to have this running with Dagger, or AndroidAnnotations. github.com/juanmendez/jm_android_dev/tree/master/…
-
Juan Mendez about 9 years@YoelGluschnaider, Ok, I wanted to confirm what I was missing before it got to work was I needed to install or have up to date. Android SDK Platform-tools ( rev. 23 rc2), as well Android SDK Build-tools.
-
IgorGanapolsky almost 9 yearsI still get an error:
Failed to apply plugin [id 'com.android.databinding']
-
Neal Sanche almost 9 yearsYes, I also had the same problem, and this answer led me to updating my android-apt to version 1.6 which solved the issue in my build.
-
Tomasz Jarosik almost 9 yearsTry to update your Android SDK support repository, developer.android.com/tools/help/sdk-manager.html
-
IgorGanapolsky over 8 yearsIs adding that databinding classpath still necessary?
-
Juan Mendez over 6 yearsThanks man, two years after it is a lot easier to include DataBinding, and it has grown elegantly. I didn't look at it for a long time and now I got to used it and fell in love with it.
-
Juan Mendez almost 6 yearsthanks Khemraj, this is an old question back in the day when DataBinding wasn't as intergrated to the Android library as it's today, still having only one single databinding direction. Frankly, I left DataBinding for so long until I found out it now supports double binding. I might end up deleting this question. It no longer applies.
-
Khemraj Sharma almost 6 yearsWhy you left data binding? I did not get you.
-
Juan Mendez almost 6 yearsfor example you have a model, and assign the attribute to an EditTextView text="@{model.name}". That was all you could do, and relied on handling the event change in the editTextView. Now you can double bind, meaning this text="@={model.name}" which means the editTextView can update name on its own without having you to add a listener and update name manually.
-
Khemraj Sharma almost 6 yearsSo that's good ? It is called two-way binding. What's wrong you find in that?
-
Juan Mendez almost 6 yearsI didn't find anything wrong, totally the opposite. Before it was a single-way databinding. That's all
-
Khemraj Sharma almost 6 yearsYes, but I found this amazing, and it reduced my code more than 50%