DirectoryNotFoundException: Could not find a part of the path 'C:\Users\maxbc\Documents\#babapaka\un

Hey guys,
For weeks I have a problem with my Android Builds…

It says it is a Gradle Daemon failure and I have the following errors.

DirectoryNotFoundException: Could not find a part of the path 'C:\Users\maxbc\Documents\#babapaka\unity\Babapaka\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\gradle\dependency-locks'.
System.IO.Enumeration.FileSystemEnumerator`1[TResult].CreateDirectoryHandle (System.String path, System.Boolean ignoreNotFound) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerator`1[TResult]..ctor (System.String directory, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerable`1+DelegateEnumerator[TResult]..ctor (System.IO.Enumeration.FileSystemEnumerable`1[TResult] enumerable) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerable`1[TResult]..ctor (System.String directory, System.IO.Enumeration.FileSystemEnumerable`1+FindTransform[TResult] transform, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles (System.String directory, System.String expression, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.InternalEnumeratePaths (System.String path, System.String searchPattern, System.IO.SearchTarget searchTarget, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.GetFiles (System.String path, System.String searchPattern, System.IO.EnumerationOptions enumerationOptions) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.GetFiles (System.String path, System.String searchPattern) (at <8f06425e63004caf99a79845675f751e>:0)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.CopyLockFiles (System.String source, System.String destination) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:224)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.GenerateAndCopyLockFiles (System.String gradleLauncherProjectLockFilesLocation, System.String assetsAndroidLockFolder, System.String gradleLauncherProject) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:155)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.OnPostGenerateGradleAndroidProject (System.String path) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:86)
UnityEditor.Android.PostProcessor.Tasks.ProcessGenerateProjectCallbacks.OnGeneratePlatformProjectPostprocess (System.String path, System.Boolean strict) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

And

Failed to run 'C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java -jar "C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" dependencies --write-locks'
stdout:

stderr:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\maxbc\Documents\#babapaka\unity\Babapaka\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':unityLibrary'.
> Could not find method aaptOptions() for arguments [build_ejk93ybebui9dd5d73rbbw6gx$_run_closure1@146d2f66] on project ':unityLibrary' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

exit code: 1

UnityEngine.Debug:Log (object)
MobileDependencyResolver.Utils.Editor.MobileDependencyResolverUtils:RunCommand (string,string,string) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/MobileDependencyResolver/MobileDependencyResolverUtils.cs:169)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject:RunGradleLockfileCommand (string) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:213)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject:GenerateAndCopyLockFiles (string,string,string) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:151)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject:GenerateAndCopyLockFilesIfRequired (string) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:168)
Unity.Mediation.Build.Editor.AndroidUpdateDependenciesPostGenerateGradleProject:OnPostGenerateGradleAndroidProject (string) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidUpdateDependenciesPostGenerateGradleProject.cs:62)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

and

DirectoryNotFoundException: Could not find a part of the path 'C:\Users\maxbc\Documents\#babapaka\unity\Babapaka\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\gradle\dependency-locks'.
System.IO.Enumeration.FileSystemEnumerator`1[TResult].CreateDirectoryHandle (System.String path, System.Boolean ignoreNotFound) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerator`1[TResult]..ctor (System.String directory, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerable`1+DelegateEnumerator[TResult]..ctor (System.IO.Enumeration.FileSystemEnumerable`1[TResult] enumerable) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerable`1[TResult]..ctor (System.String directory, System.IO.Enumeration.FileSystemEnumerable`1+FindTransform[TResult] transform, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles (System.String directory, System.String expression, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.InternalEnumeratePaths (System.String path, System.String searchPattern, System.IO.SearchTarget searchTarget, System.IO.EnumerationOptions options) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.GetFiles (System.String path, System.String searchPattern, System.IO.EnumerationOptions enumerationOptions) (at <8f06425e63004caf99a79845675f751e>:0)
System.IO.Directory.GetFiles (System.String path, System.String searchPattern) (at <8f06425e63004caf99a79845675f751e>:0)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.CopyLockFiles (System.String source, System.String destination) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:224)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.GenerateAndCopyLockFiles (System.String gradleLauncherProjectLockFilesLocation, System.String assetsAndroidLockFolder, System.String gradleLauncherProject) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:155)
Unity.Mediation.Build.Editor.AndroidLockFilePostGenerateGradleProject.GenerateAndCopyLockFilesIfRequired (System.String path) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidLockFilePostGenerateGradleProject.cs:168)
Unity.Mediation.Build.Editor.AndroidUpdateDependenciesPostGenerateGradleProject.OnPostGenerateGradleAndroidProject (System.String path) (at Library/PackageCache/com.unity.services.mediation@1.0.5/Editor/Build/PostGradle/AndroidUpdateDependenciesPostGenerateGradleProject.cs:62)
UnityEditor.Android.PostProcessor.Tasks.ProcessGenerateProjectCallbacks.OnGeneratePlatformProjectPostprocess (System.String path, System.Boolean strict) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

and

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"

Environment Variables:
USERDOMAIN = DESKTOP-0QED5G6
ProgramFiles = C:\Program Files
TMP = C:\Users\maxbc\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 5e03
OneDriveConsumer = C:\Users\maxbc\OneDrive
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_9244_RGYCAPRZVAMSFPOM
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
ProgramW6432 = C:\Program Files
USERPROFILE = C:\Users\maxbc
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
USERNAME = maxbc
NUMBER_OF_PROCESSORS = 4
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
BURST_ANDROID_MIN_API_LEVEL = 22
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
TEMP = C:\Users\maxbc\AppData\Local\Temp
Path = C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\maxbc\AppData\Local\Microsoft\WindowsApps;C:\Users\maxbc\AppData\Local\Microsoft\WindowsApps;
COMPUTERNAME = DESKTOP-0QED5G6
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
windir = C:\Windows
FPS_BROWSER_USER_PROFILE_STRING = Default
HOMEPATH = \Users\maxbc
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\maxbc\AppData\Roaming
OneDrive = C:\Users\maxbc\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\Windows
SESSIONNAME = Console
LOGONSERVER = \\DESKTOP-0QED5G6
LOCALAPPDATA = C:\Users\maxbc\AppData\Local
HOMEDRIVE = C:
USERDOMAIN_ROAMINGPROFILE = DESKTOP-0QED5G6
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\maxbc\Documents\#babapaka\unity\Babapaka\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':unityLibrary'.
> Could not find method aaptOptions() for arguments [build_ejk93ybebui9dd5d73rbbw6gx$_run_closure1@4d024d94] on project ':unityLibrary' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
]
stdout[
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <d8e4c8565d3d40da88722f68761777bc>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d8e4c8565d3d40da88722f68761777bc>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <d8e4c8565d3d40da88722f68761777bc>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, 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 <f7044ab663d344a2badf1160e57d1c1d>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I don’t know anymore what I can do… I’m so so sad to can’t build my Game for Android…
Please help me… I was so thankful for this.

sorry my English is not the yellow from the egg…

Don

That’s all right, you’re still welcome here!

The first thing I would change is to eliminate the # in your path.

Anything except A-Z and 0-9 can cause issues. Space is bad and any unicode characters are bad.

How to troubleshoot build failures:

First, make a blank project with a single blank scene and prove that it builds successfully.

If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

Until you can build a blank project to the target platform, don’t fiddle with anything else.

Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

Most often things that prevent building are third-party libraries such as Firebase.

Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

Android build not building:

Recently (circa July 2022) there have been reports of Unity’s installer failing to install the Android Tools.

https://discussions.unity.com/t/887277

Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

https://discussions.unity.com/t/891017/7

Android Gradle errors and other related stuff:

https://discussions.unity.com/t/901712/2

2 Likes

Even if your system is Windows, where # is just another character you can put into filenames, it seems like a really bad idea for anything to do with heavy shell automation. In many Unix tools, a # is the start of a comment. With careful handling, well-written Unix shell scripts can deal with # or SPACE or even \0 characters in filenames, but the chances are high that some part of a complex tool chain is going to fail on that.

1 Like

Okay thanks, I hope it will help me.
I will try the steps and give my Feedback, to help anyone other.:wink: