cren90
cren90

Reputation: 1427

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: '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!

Upvotes: 28

Views: 24868

Answers (2)

Randheer
Randheer

Reputation: 1084

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.

Upvotes: 1

sergej shafarenka
sergej shafarenka

Reputation: 20416

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.

Upvotes: 17

Related Questions