Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. 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:
    36,963
    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!