Databinding annotation processor kapt warning

cren90 picture cren90 · May 2, 2018 · Viewed 11.4k times · Source

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: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.android.databinding:compiler:3.1.2'.

Everything functions, I just hate having warnings hanging around.

Any help is much appreciated!

Answer

sergej shafarenka picture sergej shafarenka · Jul 16, 2018

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.