UnauthorizedAccessException during Unity Build for Android

Hi!
Tried to search Forums for this specific problem, but did not find a solution. I have this project I’ve been building succesfully to aab (google play store bundle) before. I haven’t change the code, I haven’t messed with settings. Only thing I did in between, I had to build something with android studio(which was horrible) and I had to play around with different gradle versions.Anyway, I come back to Unity and try to build my project from Unity to only receive error below during build (Path: d: being the directory I’m trying to build the .aab). And it should have all the writing permissions etc.

From Unity end I have default settings for gradle and JDK etc. (to use the gradle which was installed with Unity).

And as the title says it’s for Android. Apparently for IOS persistentDataPath - solution would be the fix…
Any Ideas? And thanks for the help in advance!

UnauthorizedAccessException: Access to the path "D:\" is denied. System.IO.Directory.CreateDirectoriesInternal (System.String path) (at :0) System.IO.Directory.CreateDirectory (System.String path) (at :0) UnityEditor.Android.PostProcessor.Tasks.ZipIl2cppSymbols.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0) UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0) UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0) UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Did you try building to another directory? In a folder located under C:\ for exemple

There’s something wrong with the script calling the persistentDataPath

Have a look at this question: UnauthorizedAccessException: Access to the path is denied - Questions & Answers - Unity Discussions

You might find something to help with your issue

GameObject.Save(Path.Combine(Application.persistentDataPath, "saveThis.xml"));