Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

Discussion in 'Editor & General Support' started by NivMizzer, Feb 28, 2022.

  1. NivMizzer

    NivMizzer

    Joined:
    Sep 13, 2020
    Posts:
    4
    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:

    CommandInvokationFailure: Gradle build failed.
    /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.
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,033
    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!)
     
    NivMizzer likes this.
  3. NivMizzer

    NivMizzer

    Joined:
    Sep 13, 2020
    Posts:
    4
    Yep, that solved it. Pretty crazy how such a small thing can create so many problems. Thanks!
     
    Kurt-Dekker likes this.
  4. technosoft123454321

    technosoft123454321

    Joined:
    May 16, 2022
    Posts:
    1

    Which spaces should i remove , from sdk location or from project location?
     
    Plutonosvet likes this.
  5. rpadiper

    rpadiper

    Joined:
    Jul 29, 2020
    Posts:
    3
    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!