Cannot find the setter for attribute in Data binding

I am using LiveData, DataBinding, and Kotlin in my application.

I defined a Binding Adapter for a RecyclerView like this:

   class MainListBindings {

    private val TAG = "TasksListBindings"

    companion object {

        fun setItems(recyclerView: RecyclerView, items: MutableLiveData<List<Homeitem>>? = null) {

            val adapter: RecyclerMainAdapter = recyclerView.adapter as RecyclerMainAdapter
            //prevent use of null list
            items?.let {



and my reyclerView in XML assigned to this bindingAdapter like this:


And in my ViewModel, I used

val items = MutableLiveData<List<Homeitem>>()

to create the list.

But I am getting this error at building Application:

Found data binding errors.
****/ data binding error ****msg:Cannot find the setter for attribute 'app:main_items' with parameter type android.arch.lifecycle.MutableLiveData<java.util.List<>> on file:/home/user/Yara/bazinama_mag/bazinama/app/src/main/res/layout/fragment_main.xml loc:22:24 - 22:38 ****\ data binding error ****


  • 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.