Data binding setup:
apply plugin: \'kotlin-kapt\'
android {
dataBinding {
enabled = true
}
}
dependencies {
kapt \"com.android.databind
Add
kaptTest "androidx.databinding:databinding-compiler:+"
to dependencies
on build.gradle
files of all your modules.
I have the same this issue, and fixed by adding
kapt {
generateStubs = true
}
in build.gradle app (all module if using dataBinding)
apply plugin: 'kotlin-kapt'
android {
...
dataBinding {
enabled = true
}
}
kapt {
generateStubs = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
...
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt "com.android.databinding:compiler:$android_plugin_version"
}
In build.gradle project
buildscript {
ext.kotlin_version = '1.3.70'
ext.android_plugin_version = '3.5.2'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Try to add the android-apt plugin as per this stackoverflow answer:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
A bit late, but I resolved this issue by adding DataBinding compiler with kapt as a test dependency:
kaptAndroidTest 'androidx.databinding:databinding-compiler:3.3.2'
Or the version not from AndroidX if your project is not using Jetpack yet.
I run into this very error. I did 2 things: 1. Added kaptAndroidTest 'androidx.databinding:databinding-compiler:3.5.1' in gradle 2. Used the databinding, that is to say, I create a fake bool variable and injected it for real in a view. It would seem that you cannot just use databinding for retrieving the views instead of issuing the dreaded findViewById. You have to use it at least once in your module. Once you use it you are fine for all the other classes in your module.