Kotlin-android: unresolved reference databinding Kotlin-android: unresolved reference databinding android android

Kotlin-android: unresolved reference databinding


Try use this configuration:

In main build.gradle:

buildscript {    ext.kotlin_version = '<kotlin-version>'    ext.android_plugin_version = '2.2.0-alpha4'    dependencies {        classpath "com.android.tools.build:gradle:$android_plugin_version"    //... rest of the content    }}

App build.gradle:

android {    dataBinding {        enabled = true    }}dependencies {    kapt "com.android.databinding:compiler:$android_plugin_version"}kapt {    generateStubs = true}


I found new solution, hope it will helps you.

First of all check whether plugin applied:

apply plugin: 'kotlin-kapt'

then

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

You might have an error in dependency:

USE

kapt 'com.android.databinding:compiler:3.1.4'

instead of

compile 'com.android.databinding:compiler:3.1.4'

You can visit here for new version

Thank you.

And use layout tags in layout file before using its binding class , you can easily do that :In layout file your root view (e.g.- Constraint Layout) ALT+Enter -> convert to data binding class


Update 2: This is a really old answer, instead refer to lrampazzo's answer.

It works with 1.0-rc4, put

kapt 'com.android.databinding:compiler:1.0-rc4' 

into your dependencies

Thanks Ghedeon, for the link in comments

Update: Here's a really simple hello world example project