'Unity Build Error: "System.UnauthorizedAccessException: Access to the path 'C:\Users\..\lib_burst_generated.txt' is denied."

I have a project in Unity which was built with version 2019.4.13f1. I opened it with version 2021.2.16f1 and since then when I try to build the project in an apk I get this error:

enter image description here

Also, I am getting these errors:

enter image description here

enter image description here

I tried to revert the project in the previous version and also tried a solution I found online to add to visual studio every workload possible, still nothing



Solution 1:[1]

I had the exact same issue as you with identical build exceptions after switching to 2021LTS.

I managed to work around it by going to Project Settings > Burst AOT Settings and checking off "Enable Burst Compilation" and "Enable Optimisations" for each platform, and then restarting the editor.

Of course if you need Burst compilation specifically, this won't solve your problems, but otherwise it may.

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 immho