Android Databinding: "Method references using '.' is deprecated" Android Databinding: "Method references using '.' is deprecated" android android

Android Databinding: "Method references using '.' is deprecated"


My guess is that the deprecation warning is shown because Android Data Binding is currently not being fully compatible with Java 8. Putting the following into your project's build.gradle file should hide mentioned warning.

android {    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_7        targetCompatibility JavaVersion.VERSION_1_7    }}

Unless you are using Java 8 features in your project.


The '::' error is currently an open bug for the Android Studio xml editor.


I didn't want to switch off Java 8 so I used the lambda expressions in databinding instead:

android:onClick="@{(v)->handler.onItemClick(v)}"

Here is an article by George Mount that gives lots of examples.

One thing to note is that the lambda expression is bound when the event occurs not at binding time.