This morning I made an update to android studio
from 3.0.1 to 3.1.0. After updating the gradle
to latest version I still get build error regarding
In the gradle.properties add:
android.databinding.enableV2=true
In build.gradle(module:app) file add:
dataBinding {enabled = true}
Clean project and rebuid it.
It will start working...
Following the update to Android Studio 3.2, this line works for me. I have both Java and Kotlin code (compiler) running in my project.
Add the following to your gradle.properties: android.databinding.enableV2=false
Reason:
Data Binding V2
Data Binding V2 is now enabled by default and is compatible with V1. This means that, if you have library dependencies that you compiled with V1, you can use them with projects using Data Binding V2. However, note that projects using V1 cannot consume dependencies that were compiled with V2.
source (Release Note): https://developer.android.com/studio/releases/
I had the same issue as @Marian Pavel where my project couldn't compile the databinding components unless I had the class thats used in databinding in the root folder.
I fixed the issue by doing this:
Android Studio: 3.2.1 stable
**project build.gradle**
classpath 'com.android.tools.build:gradle:3.2.1'
**module build.gradle**
apply plugin: 'kotlin-kapt'
kapt "androidx.databinding:databinding-compiler:3.2.1"
**gradle.properties**
android.databinding.enableV2=false
Just connect to internet and sync project with gradle files. It'll do.
You need to change three things when you update from Android Studio 3.0.1 to 3.1.0. This is as listed below
1) You need to change in gradle.wrapper-properties in distributionUrl. Your URL must be distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
To
2) Need to update data binding dependancy in app level gradle file from kapt 'com.android.databinding:compiler:3.0.1' to kapt 'com.android.databinding:compiler:3.1.0'
And if you are develop using kotlin then,
3) Third and last thing is need to update kotlin gradle plug in classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.30" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31" in project level gradle dependancy. Also you can update build gradle version as seen in below image.
after all above step just clean build and rebuild project. Hope it will work to solve your problem.
Thanks!! Happy coding!!
Non of these solutions worked for me so i found out its bug in 3.2 beta 4 version of android studio:
buildscript {
repositories {
...
}
dependencies {
//classpath "com.android.tools.build:gradle:3.2.0-beta04" // buggy databinding
classpath "com.android.tools.build:gradle:3.1.3" // working
}}
after this i sync, rebuild and run everyting correctly