android: data binding error: cannot find symbol class

后端 未结 26 2814
生来不讨喜
生来不讨喜 2020-12-14 05:49

I am getting started for using DataBinding feature. I am facing problem with it.

Error:(21, 9) error: cannot find symbol class ContactL

26条回答
  •  有刺的猬
    2020-12-14 06:13

    Sometimes the reason of these errors are not the DataBinding itself, but some other part of our code. In my case I had an error in Room database so the compiler couldn't generate the binding classes and it gives me these errors.

    According to Google:

    Previous versions of the data binding compiler generated the binding classes in the same step that compiles your managed code. If your managed code fails to compile, you might get multiple errors reporting that the binding classes aren't found. The new data binding compiler prevents these errors by generating the binding classes before the managed compiler builds your app.

    So to enable new data binding compiler, add the following option to your gradle.properties file:

    android.databinding.enableV2=true
    

    You can also enable the new compiler in your gradle command by adding the following parameter:

    -Pandroid.databinding.enableV2=true
    

    Note that the new compiler in Android Studio version 3.2 is enabled by default.

提交回复
热议问题