How to use Data Binding and Kotlin in Android Studio 3.0.0

UPD: This was fixed for Android Gradle plugin 3.0.0-alpha3, in yout project root build.gradle, change the buildscript dependencies to use classpath ‘com.android.tools.build:gradle:3.0.0-alpha3’ This is actually a bug in the Kotlin Gradle plugin 1.1.2-4 inter-operation with the Android Gradle plugin 3.0.0-alpha1, caused by how the inputs and outputs of the tasks are set (and thus how … Read more

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 }

Cannot find symbol DataBindingComponent on Android Studio 3.2 Canary 16 Kotlin project

Databinding libraries are being refactored as a part of androidx refactoring. I found the databinding annotation processor dependency link from google’s maven repository here. I’ve constructed the actual gradle dependency from there. kapt “androidx.databinding:databinding-compiler:3.2.0-alpha16” Update As of Android studio 3.2.0-beta01, databinding no longer needs its annotation processor dependency to be declared in the gradle file, … Read more

Android Data Binding using include tag

The problem is that the included layout isn’t being thought of as a data-bound layout. To make it act as one, you need to pass a variable: buttons.xml: <layout xmlns:andr…> <data> <variable name=”foo” type=”int”/> </data> <Button android:id=”@+id/button” ….” /> main.xml: <layout xmlns:andr… … <include layout=”@layout/buttons” android:id=”@+id/buttons” app:foo=”@{1}”/> …. Then you can access buttons indirectly through … Read more