Can't resolve Android databinding class

前端 未结 23 2142
南旧
南旧 2020-12-02 19:55

While using data binding , I am not able to get class MainActivityBinding as per Data Binding Guide

My layout name is activity_main.xml. I

相关标签:
23条回答
  • 2020-12-02 20:20

    I also faced same issue. But after updating android to androidx solved like

    try to change android.databinding.... to androidx.databinding...

    0 讨论(0)
  • 2020-12-02 20:21

    If DataBinding class name is correct and you used to clean and rebuild project but it still show error.
    Then you try to restart AndroidStudio

    0 讨论(0)
  • 2020-12-02 20:21

    I've cleaned the project , Rebuild was done...but of no use. Then invalidated caches and restarted the project that too didn't helped me.

    Then I changed my xml file name - that worked fantastically fine.

    So, I would like to share you one thing, please change your xml file name.

    For eg: If your xml file is: activity_main.xml and you can't get ActivityMainBinding in its Java class..........then change xml name to main_activity.xml and then use MainActivityBinding in its java class as 'private MainActivityBinding binding;'

    This will do most probably.

    0 讨论(0)
  • 2020-12-02 20:21

    try to review your xml, if has a value which was setted wrong. This is probably something about wrong databinding settings

    0 讨论(0)
  • 2020-12-02 20:22

    Check that you activity/fragment's xml and class have consistent names; for example, if you have TimePickerFragment than xml file name should be time_picker_fragment.

    It occurred to me that I had the layout named fragment_time_picker; after I changed it the binding was generated.

    0 讨论(0)
  • 2020-12-02 20:23

    In such cases, if neither rebuild nor invalidate caches work, then there must be an error in one of your xml files where you may have used @{xyz.abc} and there must be a problem with either xyz or abc in the xml.

    0 讨论(0)
提交回复
热议问题