Search code examples
androidandroid-studiokotlingradle-kotlin-dsl

Can't enable dataBinding even after adding plugin 'org.jetbrains.kotlin.kapt'


The build.gradle script (module) structure is:

plugin {
...
id 'org.jetbrains.kotlin.kapt'
}

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

If I try to sync my project I get:

Could not set unknown property 'enabled' for BuildType_Decorated{name=dataBinding}

And when I hover in bold enable = true instruction from dataBinding block: If you plan to use data binding in a Kotlin project, you should apply the kotlin-kapt plugin

Why is that happening if I included the plugin above? Both AS and Kotlin plugins are up to date... Is there any difference between 'kotlin-kapt' and 'org.jetbrains.kotlin.kapt'?


Solution

  • Data binding in build.gradle should be like this:

    android {
        ...
        buildFeatures {
            dataBinding true
        }
    }
    

    Source