- Home /
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&)
Answer by Mrpxl · Aug 31, 2021 at 08:23 AM
Did you try building to another directory? In a folder located under C:\ for exemple
Yes, tried multiple directories and harddrives. I had similar problem with Android Studio and the answer was changing something to the cradle file, but for the best of me, I can't remember what and where.
Answer by Riiich · Aug 31, 2021 at 08:35 AM
There's something wrong with the script calling the persistentDataPath
Have a look at this question: https://answers.unity.com/questions/1133379/unauthorizedaccessexception-access-to-the-path-is-2.html
You might find something to help with your issue
GameObject.Save(Path.Combine(Application.persistentDataPath, "saveThis.xml"));
Your answer
Follow this Question
Related Questions
I can't build a game for android 2 Answers
CommandInvokationFailure: Gradle build failed. when building app bundle 0 Answers
Distribute terrain in zones 3 Answers
Cannot build for Android 2 Answers
Build error 1 Answer