- Home /
Gradle Build Error
i moved to a new system and now unity won't build an apk using gradle.
unity: 2017.4.8| jdk: 1.8| samethings on both system.| i'm not using any plug-in or 3rd party libraries, just unity itself.
i searched and tryed for example changing value of (#org.gradle.jvmargs=-Xmx2048m) to somethings else(1024-512...) in gradle.properties file in this address (SDK\extras\google\google_play_services\samples\unified\ActivityDemo).
I welcome and appreciate any help :)
the ERROR:
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_162\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.0.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
]
stdout[
Starting a Gradle Daemon (subsequent builds will be faster)
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
screenshots from my android player settings:
Did u do that where we go to this pc properties and set environment variables ?
Answer by afshin_a_1 · Aug 07, 2018 at 11:01 AM
hey guys. after spending hours i figured out the solution. it's about setting the PATH environment variable. what made me crazy was that i could build apk before and suddenly idk it didn't work. here is what i did:
Solution:
1- Select Control Panel and then System. click on "Advanced system settings" from the left side.
2- go to Advanced tab and then "Environment Variables".
3- from the User variables for UserName(mine is Afshin), select "Path" variable and click on Edit.
4- click the New button, copy and paste the JDK directory. mine is this: C:\Program Files\Java\jdk1.8.0_162\bin
5- click ok all the windows.
Extra Solution:
close unity. be sure your internet connection is ok, then turn off your firewall. open unity and hit the build button.
everything should be ok now, you can build for android using gradle.