DataBinding not working after Upgrade Android Studio 2.3
android-apt
and hence using apt
has been deprecated since Android Studio 2.2.
Following the android-apt migration guide, instead add the following to your build.gradle
:
dependencies { classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version! annotationProcessor 'com.android.databinding:compiler:2.3.0'}
If you are using Kolin, instead use:
apply plugin: 'kotlin-kapt'dependencies { classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version! kapt 'com.android.databinding:compiler:2.3.0'}
The problem comes in a warning that is difficult to see amongst all of the errors:
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
If you remove apt, data binding works.
I have also faced the same issue.I was using ButterKnife and Dagger!!
Solved as follow
1) Remove from app level gradle file:
apply plugin: 'android-apt' or apply plugin: 'com.neenbedankt.android-apt'
2) Remove from project level gradle file:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
3) And simply change "apt to annotationProcessor" as following dependencies:
apt 'com.jakewharton:butterknife-compiler:8.5.1', apt "com.google.dagger:dagger-compiler:2.5"
To:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1',annotationProcessor "com.google.dagger:dagger-compiler:2.5"