Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

The Gradle daemon dies in the middle of a Jenkins or CI build

ErrorGradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

Short answer

The process that runs your build vanished before it reported back. Read the daemon's own log first. The usual causes are a heap that is too small for the project and too many daemons started by mixed JDKs, Gradle versions or JVM arguments, which then compete for the agent's memory.

  • Applies to Gradle 8.x and 9.x, Android Gradle plugin 8.x, Jenkins agents on Linux
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Every daemon writes a log named after its process id. Open the newest one for your Gradle version; its last lines say what the daemon was doing.

    ls -t ~/.gradle/daemon/*/daemon-*.out.log | head -3
    tail -n 60 "$(ls -t ~/.gradle/daemon/*/daemon-*.out.log | head -1)"
  2. 2Match what you see, then jump to its fix

    1. 1A big Android build dies at the same step each time, and no org.gradle.jvmargs line existsThe daemon heap is too small for this projectFix
    2. 2Several GradleDaemon processes are alive on the agent at the same timeMixed JDKs, Gradle versions or JVM arguments start extra daemonsFix

What does the error look like?

  • Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

Cause 1 of 2

The daemon heap is too small for this project

1Check

A daemon that gets no maximum heap setting is limited to 512MB. Look for the setting in the project and in the user home.

grep -n "org.gradle.jvmargs" gradle.properties ~/.gradle/gradle.properties

2Fix

Set a larger heap for the daemon, using a value the agent can actually spare.

# gradle.properties
org.gradle.jvmargs=-Xmx2048M

3Verify

Run the job again; a daemon with the new arguments is started.

./gradlew assembleRelease

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 2

Mixed JDKs, Gradle versions or JVM arguments start extra daemons

1Check

A daemon is reused only when its Java home and JVM arguments match, so a different JDK, Gradle version or jvmargs value starts another one, using more CPU and memory.

jps | grep -i GradleDaemon

2Fix

Use one JDK and one wrapper version across jobs that share an agent, then stop the leftover daemons.

./gradlew --stop
./gradlew --version

3Verify

After the next build only one daemon is listed.

jps | grep -i GradleDaemon

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Pin the Gradle version through the wrapper and the JDK through the Jenkins tool configuration.
  • Set org.gradle.jvmargs in the repository so every agent starts the daemon the same way.
  • Keep the daemon log directory when a build fails, so the cause is not lost with the workspace.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.