Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Open Wrong File When Trying to Open XML layout file [duplicate]

I am using android studio 3.3, my project is using kotlin 1.3.20 with build gradle 3.3.0

however when i try to open xml file, it open different file with the right file name and the right file path:

enter image description here

And when i try to see this xml file in my Git, my file is normal

enter image description here

when i try to run this project, it run with no problem at all. i already try to invalidate caches/restart but the problem still exist.

this error affecting random xml files. some of my xml layout files open my kotlin file. some of them open auto generated file

please help.... is this something to do with error indexing? how can i fix this?

UPDATE :

found someone who might have the same problem with this, in google issue tracker : https://issuetracker.google.com/issues/122988154

UPDATE 2 :

this issue is not just happen in xml file but also in kotlin file.

i try to open my activity file, but it open one of data binding generated classes

like image 411
wood wood Avatar asked Nov 06 '22 21:11

wood wood


1 Answers

So Apparently this issue is bug in Android Studio. after do some research, this bug might be happen not just to xml layout but other xml file too such as resource like dimens, strings, style etc..

finally there is some workaround for this issue that work without reinstall Android Studio. Thank you @ChetanJoshi for the suggestion in the comment section.

Steps:

  • Copy the error xml file to somewhere in your PC directory (as backup file)
  • Delete the error xml file, if there is dialog file usage appear klik delete anyway
  • Copy the backup file and paste it back to where it was deleted
  • Run your project. it should run
  • If you are using Data Binding and there is error appear about auto generated data binding class, Clean Project then rebuild project. if the error still appear try to invalidate caches/restart, rebuild project then run the project
like image 167
wood wood Avatar answered Nov 11 '22 12:11

wood wood