Why did the Gradle Daemon die?

2019-05-21 12:42发布

问题:

How do I determine why my Gradle Daemon died? The only message I get isL

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

This occurs in an active build. Several steps will finish and a step will appear to be active and then the build fails.

This began after moving our memory args (Xmx Xms PermGen) from a shell script that called gradlew to gradle.properties and calling gradlew directly.

build.sh

export GRADLE_OPTS="\"-Xmx1024m\" \"-Xms256m\" \"-XX:MaxPermSize=256m\""
export JAVA_HOME="/usr/local/java/jdk1.6"
exec ./gradlew "$@"

Addition to gradle.properties

org.gradle.java.home=/usr/local/java/jdk1.6/
org.gradle.jvmargs=-Xmx1024m -Xms256m -XX:MaxPermSize=256m

After this change Gradle warns:

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html

And even though we don't ask it to, the build is running in a daemon, which ultimately fails.

回答1:

Gradle build daemon disappeared unexpectedly most frequently occurs when something else kills the long-running Gradle Daemon process and the client process (the Daemon uses local TCP connections to communicate) tries to send a message and gets no response.

For example, running gradle --stop or killall java while a build is occurring will reproduce this problem.