Il2cpp.exe didn't catch exception: System.IO.IOException: Access to the path '{path}' is denied

Hi,

For reference, I am using Unity 2019.4.9f1 and building with Android API 30.

I have searched every corner of the internet and I am unable to find a solution.

This error is strange as it has appeard randomly after I have done countless builds for Android in the past. I’m thinking maybe Windows update broke something.

Each time I build for Android (using IL2CPP for both ARMv7 and ARM64 architectures) I am getting the following errors:

Failed running C:\Program Files\Unity\Hub\Editor\2019.4.9f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe --compile-cpp --libil2cpp-static --platform=“Android” --architecture=“ARM64” --configuration=“Release” --outputpath=“C:\Users\omar1\OneDrive\Desktop\PixiRabbit\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a\libil2cpp.so” --cachedirectory=“C:\Users\omar1\OneDrive\Desktop\PixiRabbit\Assets..\Library\il2cpp_android_arm64-v8a/il2cpp_cache” --additional-include-directories=“C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include” --additional-include-directories=“C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include” --tool-chain-path=“C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK” --map-file-parser=“C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe” --generatedcppdir=C:/Users/omar1/OneDrive/Desktop/PixiRabbit/Temp/StagingArea/Il2Cpp/il2cppOutput --dotnetprofile=“unityaot”

stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: C:\Users\omar1\OneDrive\Desktop\PixiRabbit\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a
Cache directory: C:\Users\omar1\OneDrive\Desktop\PixiRabbit\Library\il2cpp_android_arm64-v8a\il2cpp_cache
ObjectFiles: 157 of which compiled: 0
Total compilation time: 115 milliseconds.
il2cpp.exe didn’t catch exception: System.IO.IOException: Access to the path ‘C:\Users\omar1\OneDrive\Desktop\PixiRabbit\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_8E417845F41A6236948E52CE0D7BBBA7’ is denied.
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at NiceIO.NPath.Delete(DeleteMode deleteMode)
at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet1 objectFiles, CppToolChainContext toolChainContext) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[ ] args, List1 foundAssemblies)
at il2cpp.Program.Run(String[ ] args, Boolean setInvariantCulture)
at il2cpp.Program.Main(String[ ] args)
stderr:

Unhandled Exception: System.IO.IOException: Access to the path 'C:\Users\omar1\OneDrive\Desktop\PixiRabbit\il2cpp\linkresult_8E417845F41A6236948E52CE0D7BBBA7' is denied.
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at NiceIO.NPath.Delete(DeleteMode deleteMode)
at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet1 objectFiles, CppToolChainContext toolChainContext) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[ ] args, List1 foundAssemblies)
at il2cpp.Program.Run(String[ ] args, Boolean setInvariantCulture)
at il2cpp.Program.Main(String[ ] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action1) UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List1, Action1, String) UnityEditorInternal.IL2CPPBuilder:RunCompileAndLink() UnityEditorInternal.IL2CPPUtils:RunCompileAndLink(String, String, IIl2CppPlatformProvider, Action1, RuntimeClassRegistry)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

I have tried:

  • reinstalling Unity 2019.4.9f1
  • reinstalling the Android module and il2cpp module
  • running Unity as admin
  • using Android 29 instead of 30
  • restarting my computer
  • moving the project to my desktop
  • deleting Library\il2cpp_android_arm64-v8a\il2cpp_cache

and still no luck.

Any suggestions or help on this issue will be greatly appreciated.

Thanks,
Omar

1 Like

I had the same error. As much as I don’t have a solid answer, this fixed it:

  1. Deleted the folder that starts with “linkresult” in the error. In your case C:\Users\omar1\OneDrive\Desktop\PixiRabbit\il2cpp\linkresult_8E417845F41A6236948E52CE0D7BBBA7

  2. Copied the NDK and SDK folders from another machine that could build without errors and used the copied folders rather than what Unity provides. You can change the NDK and SDK paths in Preferences → External Tools.

So deleting that folder mentioned in the error and replacing both NDK and SDK solved it for me.