'Android Studio build keeps crashing (stableIds.txt The data is invalid. (13))

I've been trying to run my android studio app but android studio keeps giving me this build error for all of my projects.

Full error is this:

ERROR:: AAPT: <App Location>\app\build\intermediates\stable_resource_ids_file\debug\stableIds.txt: error: failed to open: The data is invalid. (13).

I tried making fresh projects too but that didn't seem to fix it. I didn't change anything in those projects. I also checked and there is no stableIds.txt. This issue didn't happen before too so I'm even more confused.



Solution 1:[1]

I was experiencing the same issue... my anti virus program (AVG) was the culprit. AVG was silently preventing Android Studio from working properly...despite having already turned off AVG's File Sheild, and Behaviour Sheild. I fixed this by:

solution 1

  1. turning off AVG's Ransomeware Protection should also prevent this from ever happening again.

solution 2

  1. restarting my computer (only worked for me after i restarted for 2nd time)
  2. open the project in android studio
  3. try to deploy the app onto a device
  4. wait for a popup from AVG to appear, asking if you want to prevent aapt2.exe from modifying stableIds.txt
  5. allow it..
  6. build the app without any issues!

Solution 2:[2]

This Problem occurs when Ransomware Protection > Controlled Folder Access is turned on in Windows Defender. To fix it, Go to Windows Defender > Ransomware Protection and Turn Off Controlled Folder Access. If You have a different antivirus, they may also have similar settings which might prevent Android Studio from functioning normally.

This fix worked in my case...

Solution 3:[3]

Most Likely an Anti-Virus problem

Temporarily disabling the anti-virus program for a few minutes solved this problem for me.

  1. Close Project in Android Studio (File > Close Project)
  2. Disable Anti-Virus.
  3. Re-open the project and run the app.

Solution 4:[4]

The Problem With Gradle version enter gradle.build and change gradle to previous version. enter image description here

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
Solution 2 Jeswin Joji
Solution 3 Simon1GA
Solution 4 Ahmed Godaa