X Tutup
Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

AndroidAnnotations not compatible with DataBinding on Android Studio 3.0 #2074

@couchcrew-thomas

Description

@couchcrew-thomas

AndroidAnnotations version: 4.3.1

Android compile SDK version: 26

Description:
When using DataBinding adapters on @EViews the DataBinding compiler fails. Everything worked fine under gradle 2.3.3.

Annotated code:

@EView
public class BindingViewAA extends AppCompatTextView {

    @BindingAdapter("data")
    public static void setData(BindingViewAA view, BindingData data) {
        view.setText(data.getBar() + data.getFoo());
    }

    public BindingViewAA(Context context) {
        super(context);
    }

    public BindingViewAA(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BindingViewAA(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
}

Layout:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
    >

    <data>

        <variable
            name="greeting"
            type="String"/>

        <variable
            name="data"
            type="com.example.databinding_aa.databindingaa.BindingData"/>

    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:orientation="vertical">

        <com.example.databinding_aa.databindingaa.BindingViewAA_
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:data="@{data}"/>

    </LinearLayout>
</layout>

Compile error:

Error:(39, 25) Cannot find the setter for attribute 'app:data' with parameter type com.example.databinding_aa.databindingaa.BindingData on com.example.databinding_aa.databindingaa.BindingViewAA_. 

Example project:
Example Github Project

  • If you comment the BindingViewAA_ view from the layout everything works.
  • It worked fine in Android Studio 2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup