Gradle build daemon disappeared unexpectedly

Hi guys. I am facing Daemon disappeared consistently, and don’t have an idea to solve that.
I tried many things but couldn’t find robust solution. Does any one has an idea about this?

config.yml

android_config: &android_config
    working_directory: *workspace
    docker:
      - image: runmymind/docker-android-sdk:latest
    environment:
      TERM: dumb
      JVM_OPTS: "-Xmx4096m"
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx4096m" -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.daemon=false'
  gcloud_config: &gcloud_config
    working_directory: *workspace
    docker:
      - image: google/cloud-sdk:latest
    environment:
      TERM: dumb
  default_config: &default_config
    working_directory: *workspace
    docker:
      - image: runmymind/docker-android-sdk:latest
build_debug:
    <<: *android_config
    steps:
      - checkout
      - *restore_cache
      - run:
          name: Download dependencies
          working_directory: ~/workspace/MyApp
          command: ./gradlew androidDependencies
      - *save_cache
      - run:
          name: Gradle build (assembleDebug)
          working_directory: ~/workspace/MyApp
          command: ./gradlew --no-daemon -PciBuild=true :app:assembleDebug --stacktrace
      - run:
          name: Gradle build (assembleAndroidTest)
          working_directory: ~/workspace/MyApp
          command: ./gradlew --no-daemon -PciBuild=true :app:assembleAndroidTest --stacktrace
      - *persist_debug_workspace
      - store_artifacts:
          path: MyApp/app/build/outputs/apk/
          destination: /apk/
FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* 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:238)
	at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:214)
	at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:178)
	at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:54)
	at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:36)
	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
	at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:291)
	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:264)
	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:257)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:191)
	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:60)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
	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.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)


* Get more help at https://help.gradle.org
Exited with code 1

It might have run out of memory, and then killed off by the kernel. Get an SSH session into a failing build and look at the end of dmesg to see if this is the case.

For me ./gradlew assembleRelease has been working be fine. Mine runs nightly, so I’ll let you know if I get the same Gradle build daemon error.

FYI, I do not have the "JVM_OPTS: -Xmx " setting.

If yours is failing consistently, you may want to try this blog’s suggestion from Circleci - https://circleci.com/blog/how-to-handle-java-oom-errors/ and let us know the result :slight_smile: I may have to do the same in future.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.