Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) while building Android project on Jenkins

I have an Android Project that builds successfully on Android Studio.

Now I want to build it on Jenkins. But when I'm doing I got the following error: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

Exception is:

org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)     at org.gradle.launcher.daemon.client.DaemonClient.handleDaemonDisappearance(DaemonClient.java:222)     at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:198)     at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:162)     at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:125)     at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:80)     at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)     at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:241)     at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:214)     at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)     at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:207)     at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)     at org.gradle.launcher.Main.doAction(Main.java:33)     at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:498)     at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)     at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)     at org.gradle.launcher.GradleMain.main(GradleMain.java:23) 

I read related topics, but it does not help. I tried to build it using gradle daemon, and without it, but the problem still exists.

like image 995
Sandro Gedevanishvili Avatar asked May 11 '16 18:05

Sandro Gedevanishvili


2 Answers

EDIT Looks like there has been a few changes with the new versions of Gradle.

Since 3.0 you should not disable the daemon on your CI anymore

[We] recommend using [the daemon] for both developers' machines and Continuous Integration servers.

However, if you suspect that Daemon makes your CI builds unstable, you can disable it to use a fresh runtime for each build since the runtime is completely isolated from any previous builds.

PREVIOUS ANSWER

It's recommended to turn off daemon on any CI server. use this option to disable it

--no-daemon 
like image 110
Oleg Khalidov Avatar answered Oct 03 '22 23:10

Oleg Khalidov


After getting this crash I tried several things to get the GradleDaemon to stop running on my CI server. None of which worked.

I found an answer on a gradle.org forum which suggested that the GradleDaemon would always run anyway. The --no-daemon flag would just make it run for this specific build rather than staying on indefinitely.

If you specify JVM arguments that require forking, Gradle will fork a new JVM. Regardless of whether or not you want a daemon process, the class that runs is called GradleDaemon. The --no-daemon switch should cause the forked process to be single use instead of a long running daemon process, but it's still going to run the GradleDaemon class.

Source: https://discuss.gradle.org/t/no-daemon-switch-ineffective-if-jvm-settings-cause-new-fork/14919/5

I may be reading this wrong and I can't vouch for the validity of the answer, but I think the cause of this error is just a lack of memory for Gradle. As it is always going to run the GradleDaemon.

So I added

org.gradle.jvmargs=-Xmx1024m  

to my ~/.gradle/gradle.properties file and it no longer gave me that error.

like image 26
MungoRae Avatar answered Oct 03 '22 23:10

MungoRae