Skip to content Skip to sidebar Skip to footer

Databinding Annotation Processor Kapt Warning

In my app module's build.gradle, I have added dependencies { kapt('com.android.databinding:compiler:3.1.2') ... } but I'm still receiving the compiler warning for app: 'annotati

Solution 1:

I had same warnings until I upgraded to the latest Android Gradle build plugin and Kotlin. Now they are gone. Here is the configuration I use.

project.gradle

buildscript {
    dependencies {
        classpath "com.android.tools.build:gradle:3.1.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"
    }
}

module.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    ...
    dataBinding {
        enabled = true
    }
}

dependencies {
    // no kapt declaration for databinding here
}

Hope it helps.

Solution 2:

Add following in you app build.gradle

kapt "com.android.databinding:compiler:$android_plugin_version"
apply plugin: 'kotlin-kapt'// This one at top where plugin belong to

This will do the trick.

$android_plugin_version is version of com.android.tools.build:gradle in application build.gradle

Also, add this to your module build.gradle

android {
    /// Existing Code
    kapt {
        generateStubs = true
    }
}

You are missing apply plugin: 'kotlin-kapt' i think.

Post a Comment for "Databinding Annotation Processor Kapt Warning"