what is the actual root cause of this issue? I already sync with gradle files but eventually failed.
Just sync your project with gradles. File --> Sync Project with Gradle Files
If nothing of the above steps work, Then simply undo the changes that you have recently made, and then build gradle. In my case, I have added one dependencies and this problem raised, so I removed that dependencies build the gradle and then again add it. Problem Solved..!!
I had this problem and it was because I didn't have the right API level installed (and I was also getting an error to that effect). I went into Tools --> SDK Manager and installed the API the system was telling me I needed (in my case, 30). I did that and restarted Android Studio and was able to get into XML files.
Just you have to do >> open File --> Sync Project with Gradle Files and then after >> open File --> invalidate Android Studio caches / restart so done this problem.:)
Issue happened to me when I changed the res>values>styles.xml
What I change was
"Theme.AppCompat.Light.DarkActionBar"
--->>> "Base.Theme.AppCompat.Light.DarkActionBar"
Solutions I tried.
Build -> Clean Project
Build -> Rebuild Project
File -> Sync project with gradle files . If not worked then try
File -> Invalidate Caches / Restart .
It's work for me !!!