Can't build to android! (CommandInvokationFailure: Gradle build failed)

I’m having a problem with not being able to build my unity projects to android. Whenever I try, I get a popup saying “Gradle Build Failed” and a couple of errors in the console:

/Applications/Unity/Hub/Editor/2020.3.30f1/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -classpath "/Applications/Unity/Hub/Editor/2020.3.30f1/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"```

and

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
WARN: /Users/me/Desktop/Programming/unity_projects/Stack It (No such file or directory): /Users/me/Desktop/Programming/unity_projects/Stack It
java.io.FileNotFoundException: /Users/me/Desktop/Programming/unity_projects/Stack It (No such file or directory)


Can anyone help fix this problem? Even after trying to install a different version of unity I can't get it to work.

![7932121--1013416--Screen Shot 2022-02-28 at 21.59.51.png|2152x536](upload://i8wVj4wO6ItQuFy0XqWiy1bHyvc.png)

Try removing spaces from your directory names. This has been an issue with some toolchains.

I know, it’s 2022 but spaces in filenames were never a good idea to begin with, so there you have it.

(Obviously close Unity and everything using that folder before renaming it!)

1 Like

Yep, that solved it. Pretty crazy how such a small thing can create so many problems. Thanks!

1 Like

Which spaces should i remove , from sdk location or from project location?

1 Like

For me it was having my project in an external drive, spent all day trying to fix this. Moved it to my documents folder, and the build ran flawlessly. Wish you luck!