'Android Studio replacing random files

Android Studio is replacing files in my projects. It mainly affects layout files. Mostly it looks like this: enter image description here

Most of the time the app is still able to build and run without errors. I can easily restore these files through Git, but it's really annoying.

This doesn't appear for any reason, like a crash or something like that.

I'm running Android Studio 4.0.1 Build #AI-193.6911.18.40.6626763, built on June 25, 2020 Runtime version: 1.8.0_242-release-1644-b01 amd64

Has anyone encountered something similar and knows how to fix it?



Solution 1:[1]

Erasing the cache of Android Studio will resolve the issue. to do this go to /.AndroidStudio4.0/system/caches/ folder and delete all the files in this folder.

Solution 2:[2]

i was facing that issue

copy your code and move it to other directory then Delete Top 2 folders named(.gradle and .idea) and also delete all .iml files then import this project (do not open project use import project)

Solution 3:[3]

you can solve this issue >> kindly reinstall android studio . several days before i got this issue .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Moinuddin
Solution 2 a_local_nobody
Solution 3 Ajay Pawar