Databinding compiles but shows error in Android Studio 3.6

Viewed 2052

Since the new Android Studio 3.6 update, my databinding classes show "Cannot resolve symbol"

The code itself is completely fine and it even compiles successfully, but everywhere I'm calling the binding classes, Android Studio gives me the "Cannot resolve symbol" error. This goes through every class or xml I'm using databinding in.

Did anyone of you experience the same? It seems weird, that the update to 3.6 did that. Gradle version used is 3.6.1

Thank you!

Edit: I for now have taken every step I can as a developer, reconfigured everything, tried on different machines etc. I'm not sure if this is a problem of the project I'm working on or a bug of 3.6 that only occurs when some criterias are met, since I'm not the only one, having this exact problem. Below is a screenshot of it to give you an idea how it looks.

Screenshot of the Problem

Final Edit

Seems like upgrading to the Android Studio 4.0 Beta 1 fixed the problem for me now. This seems to be an Android Studio 3.6 related issue. Don't know if using a beta version is a possible solution for you, but for me this solved it completely

6 Answers

Seems like upgrading to the Android Studio 4.0 Beta 1 fixed the problem for me now. This seems to be an Android Studio 3.6 related issue. Don't know if using a beta version is a possible solution for you, but for me this solved it completely

What works for me is going into a layout xml file, removing/adding/changing text in it, then putting the file back to normal (ctrl-z). Then the "errors" disappear. I'm specifically using Kotlin, so perhaps it's only a Kotlin issue? Does the same thing to me with viewbinding as well (same "fix")

Solved same issue with next steps:

  1. comment all codelines where binding class is used
  2. run Build->Rebuild Project
  3. uncomment all lines from step 1

Looks like sometimes AS can't generate Binding class cause your code links to it but class doesn't exist. Some kind of cyclic dependency

I rewrote <layout> tag in all my layouts, and it is helped me.

This is really annoying, for it fixes when I clean and rebuild the project

Just Clean your Project and that's it.

Related