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