Cannot find the setter for attribute in Data binding

There might be different reasons for this error but in my case, the problem raised up because I didn't add apply plugin: 'kotlin-kapt' And apply plugin: 'kotlin-android-extensions' in my Gradle.

After adding these plugins you have to replaced your annotationProcessors with kapt.

After that, every thing might be going well.


Binding Adapter

    @JvmStatic
    @BindingAdapter("main_items")
    fun setItems(recyclerView: RecyclerView, items: MutableLiveData<List<String>>) {

    }

Model

 class User : ViewModel(){
        lateinit var list: MutableLiveData<List<String>>
    }

Bind Data

 val items = ViewModelProviders.of(this@FragmentName)
                .get(RecyclerViewHelper.User::class.java)
    mBinding!!.user = items

Layout

<layout>
     <data>
        <variable
            name="user"
            type="com.XXX.view.recylerview.RecyclerViewHelper.User" />
    </data>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/helper_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layoutManager="android.support.v7.widget.LinearLayoutManager"
            app:main_items="@{user.list}" />

    </RelativeLayout>

</layout>