5

After a random crash on Android Studio, a lot of my code is being opened by Android Studio as if it was an XML or R.class.

Sample of Corrupted File 1

Sample of Corrupted File 2

Explaning it better: It does correct itself after a fresh install of Android Studio (any version), and it hasn't happened in 3.1.4, but I'm using features from 3.2. After less than 6h coding, a random crash happens on Android, I report it by the AS and this suddenly happens to many of my files, not allowing me to build it again until I reinstall Android entirely.

I'm running AS as an Administrator, and I do have permission everywhere. My project is not corrupted nor are my files, since every single fresh install simply brings my code back and I can code until any/a random crash happens, creating this AS/Gradle corruption.

As you can tell, even when "corrupted" on AS, my code is actually fine when opened with any external editor, so reverting back my Git code is not enough to make me get rid of this problem (I wish).

Some important things I already tried:

  • Clear Cache and Restart Android Studio
  • Use Android 3.2.1 and 3.3 RC
  • Rebuild Project
  • Resync with Gradle, FileSystem, etc, etc...
  • Clear caches from /user/.gradle/caches and from /user/.AndroidStudio3.3/system/caches
  • Delete .idea and .gradle from the project's folder
  • Reinstall Android Studio (also tried with both versions)

I found a related issue here, but the guy simply deleted both of those files. But that's something I can't do, since this is happening with my project files. This related issue can be found here.

I also found another 3 or 4 posts, which where never answered with a valid answer and that were "never solved" or were solved by installing a new version of AS. But I'm already trying the Beta and this error/problem persists....

Consider this post a cry for help. This is haunting me in my development in such a way that I simply can't program more than 6 hours before getting this bizarre behavior in each and any newer version of AS.

References:

Related by @Vengat

Related by @CanProgram (since 2.3.3?)

Related by @RmGetty Bautista

Related at KeepCoding

  • I was also facing a similar issue not a while ago. Tried all the options you mentioned but nothing worked. I eventually had to delete the existing version of Android studio(including my custom settings) and re-download it again. Then I faced the same issue again. I think the problem is with Android Studio's latest version (3.2.1), I'm now using version 3.1 and everything is working well – Oush Nov 30 '18 at 12:56
  • 1
    That's so sad.... I also tried 3.3 RC and I faced the same problem... Seems like I'll have to go back to 1.4 again, and stick to it. I really wish this was addressed by Google as soon as possible, since this is a serious Development break. – Marcelo Petrucelli Nov 30 '18 at 13:07
  • Solution for latest android studio https://stackoverflow.com/a/68746941/5773037 – Nikunj Paradva Aug 11 '21 at 18:13

1 Answers1

-1

Tbh, android studio sucks at that part. If you encounter that problem, then r.i.p to your code. The way I tried to minimized the chance of getting my file corrupted is by closing the emulator whenever I finished running the program, and also when it works properly, I copy all the files to a notepad just in case something bad happen. *and yes it happened right when I wanted to show my assignment in front of my lecturer, thanks to notepad I can retrieve it back