Android Studio unresolved reference. Project compiles
Simple Solution Is That:
1: GoTo File And Close The Project.
2: Then GoTo File And Click On "Open Recent" And Open Your Project.
That Trick Works For Me.
Please Delete the .idea and .gradle project from the app directory and Invalidate and Cache Restart the Android Studio. This will resolve this issue.
I agree with Stanislav Mukhametshin that may be it is related with new AndroidX libraries and migration on it. I had cleaned and rebuilt project but that didn't work. So, I tried this way and error goes away.
1) Go to File
and close project.
2) Reopen the same project.
I had the same problem. It is related with new AndroidX libraries and migration on it.
Try File -> Open -> and click build.gradle to reopen project.