When building a project in Android Studio, you may encounter an error or message stating “Gradle build daemon has been stopped”.
This message appears when the Gradle Daemon that was executing the Gradle build process has stopped.
Possible causes include manually stopping the Gradle Daemon, insufficient memory, incompatible JDK and Gradle versions, abnormal termination of the Gradle Daemon, restarting Android Studio, changes to Gradle settings, and cache problems.
This article explains the main causes and solutions in order when “Gradle build daemon has been stopped” appears in Android Studio.
- What Is “Gradle build daemon has been stopped”?
- Cause 1: The Gradle Daemon Was Manually Stopped
- Cause 2: Android Studio Was Restarted
- Cause 3: The Gradle Daemon Was Stopped After Being Unused for a Period of Time
- Cause 4: Gradle Settings Were Changed
- Cause 5: The JDK Was Changed
- Cause 6: The Gradle and JDK Versions Are Incompatible
- Cause 7: There Is a Compatibility Problem Between the Android Gradle Plugin and Gradle
- Cause 8: Insufficient Memory for the Gradle Daemon
- Cause 9: The Entire PC Is Running Low on Memory
- Cause 10: The Gradle Daemon Is Terminating Abnormally
- Cause 11: There Is a Problem with the Gradle Cache
- Cause 12: There Is a Problem with the .gradle Directory in the Project
- Cause 13: The Gradle Daemon Is Disabled
- Cause 14: Multiple Gradle Daemons Are Running
- Cause 15: Android Studio and the Terminal Are Using Different JDKs
- Cause 16: There Is a Problem with the JAVA_HOME Setting
- Cause 17: The Java Process Is Crashing
- Cause 18: The Process Was Terminated by Android Studio or the Operating System
- Solutions to Check First
- First Restart the Gradle Daemon
- Check the Status of the Gradle Daemon
- Check the Gradle and JDK Combination
- Check the Gradle Daemon Settings
- Check Gradle’s Memory Settings
- Check Detailed Errors
- Check the Daemon Log
- Difference Between “Gradle build daemon has been stopped” and “Gradle build daemon disappeared unexpectedly”
- Do Not Judge the Cause from the First Message Alone
- Summary
What Is “Gradle build daemon has been stopped”?
Gradle uses a background process called the Gradle Daemon to speed up the build process.
Once started, the Gradle Daemon may be reused for multiple builds.
If this Daemon stops for some reason, a message like the following may appear.
Gradle build daemon has been stopped
This message itself does not necessarily indicate a serious error.
It may also appear when the Gradle Daemon is intentionally stopped or when an old Daemon terminates because of configuration changes.
On the other hand, if the message appears repeatedly during a build or the build fails afterward, you need to check for issues such as insufficient memory or JDK and Gradle compatibility.
Cause 1: The Gradle Daemon Was Manually Stopped
Gradle allows you to stop running Gradle Daemons with the following command.
./gradlew --stop
When this command is executed, the Gradle Daemon stops normally.
If you run a build afterward, a new Gradle Daemon starts as needed.
Therefore, if you intentionally ran ./gradlew --stop immediately beforehand, seeing “Gradle build daemon has been stopped” does not necessarily indicate a problem.
Cause 2: Android Studio Was Restarted
When Android Studio is closed or restarted, the state of Gradle-related processes may change.
After the restart, a new Gradle Daemon may start, and a message indicating that the previous Daemon was stopped may appear.
If the message appears only immediately after restarting Android Studio and builds work normally afterward, it may not be a major problem.
Cause 3: The Gradle Daemon Was Stopped After Being Unused for a Period of Time
The Gradle Daemon does not always continue running forever.
Gradle may stop it after it has not been used for a certain period of time.
When a new build starts afterward, a new Daemon starts as needed.
In this case as well, if the next build runs normally, there is generally no problem.
Cause 4: Gradle Settings Were Changed
If you change settings such as those in gradle.properties, the Gradle Daemon that was previously being used may no longer match the new settings.
For example, this can occur if you change JVM settings like the following.
org.gradle.jvmargs=-Xmx2048m
To run the build with the new settings, the previous Daemon may be stopped and a new Daemon may start.
If the message appears only immediately after changing settings, it may be normal behavior.
Cause 5: The JDK Was Changed
If you change the Gradle JDK in Android Studio or JAVA_HOME, a Gradle Daemon that was running with the previous JDK may no longer be reusable.
As a result, the old Daemon may be stopped and a Daemon using the new JDK may start.
You can check the Java version with the following command.
java -version
You can check the JVM actually used by Gradle with the following command.
./gradlew --version
If the issue occurs immediately after changing the JDK, check whether Gradle is using the intended JDK.
Cause 6: The Gradle and JDK Versions Are Incompatible
The supported Java versions differ depending on the Gradle version.
If an unsupported JDK is used, the Gradle Daemon may fail to start correctly or may stop immediately after starting.
The Gradle version can usually be checked in gradle-wrapper.properties.
distributionUrl=https\://services.gradle.org/distributions/gradle-8.x-bin.zip
Check whether the combination of Gradle and the JDK is supported.
Cause 7: There Is a Compatibility Problem Between the Android Gradle Plugin and Gradle
In Android projects, not only Gradle and the JDK but also the Android Gradle Plugin (AGP) version is involved.
If only Gradle is updated or only the Android Gradle Plugin is updated, a compatibility problem may prevent the build from starting correctly.
For Android projects, check the combination of Gradle, the Android Gradle Plugin, and the JDK.
Cause 8: Insufficient Memory for the Gradle Daemon
If the amount of memory allocated to the Gradle Daemon is insufficient, the Daemon may stop during the build.
Large Android projects or projects containing many libraries and modules may use more memory during the build.
You can configure Gradle JVM memory in gradle.properties.
org.gradle.jvmargs=-Xmx2048m
If insufficient memory is suspected, check the setting while considering the amount of memory installed in the PC.
If the memory setting is too large, the entire PC may run out of available memory and become unstable instead. Check not only Gradle but also the memory usage of Android Studio, the emulator, and other applications.
Cause 9: The Entire PC Is Running Low on Memory
Even if there is no problem with the Gradle Daemon settings, the operating system may stop the Java process if the entire PC is running low on available memory.
Using Android Studio, Android Emulator, a browser, Docker, virtual machines, and other applications at the same time may result in high memory usage.
Close unnecessary applications and run the build again.
Cause 10: The Gradle Daemon Is Terminating Abnormally
If the Gradle Daemon terminates abnormally because of an internal error, a message related to “Gradle build daemon has been stopped” may appear.
If the problem is temporary, stopping all Daemons once and then running the build again may resolve it.
./gradlew --stop
After that, run the build again.
./gradlew build
Cause 11: There Is a Problem with the Gradle Cache
Gradle stores dependency libraries, build information, and other data as a cache.
If the cache is inconsistent or corrupted, the Gradle Daemon may become unstable.
To retrieve dependencies again, you can use the following command.
./gradlew build --refresh-dependencies
After that, run Gradle Sync or the build again and check whether the issue improves.
Cause 12: There Is a Problem with the .gradle Directory in the Project
A .gradle directory may be created inside a Gradle project to store project-specific cache and state information.
If this information becomes inconsistent, the Gradle Daemon or build process may fail to operate correctly.
After closing Android Studio and Gradle, regenerating the Gradle cache inside the project may resolve the issue.
When deleting caches, make sure that the target is a cache that will be regenerated by Gradle.
Cause 13: The Gradle Daemon Is Disabled
The Gradle Daemon may be disabled in gradle.properties.
org.gradle.daemon=false
With this setting, Gradle behaves differently from normal Daemon usage.
If you want to use the Gradle Daemon continuously, check whether this setting is included in the project’s or user’s gradle.properties.
Cause 14: Multiple Gradle Daemons Are Running
If different Gradle versions, JDKs, or JVM options are being used, multiple Gradle Daemons may start.
Immediately after changing the environment, a Daemon that was running with the previous settings may remain.
Stopping the current Daemons once can help reset the state.
./gradlew --stop
After that, start a new Daemon with the current settings.
Cause 15: Android Studio and the Terminal Are Using Different JDKs
Android Studio allows the Gradle JDK to be configured separately.
Therefore, the Java used in the terminal may differ from the Java used when Gradle is run from Android Studio.
In the terminal, check the following command.
java -version
You can check the JVM used by Gradle with the following command.
./gradlew --version
Also check the Gradle JDK in Android Studio and confirm that each environment is using the intended JDK.
Cause 16: There Is a Problem with the JAVA_HOME Setting
When running Gradle from the terminal, JAVA_HOME may affect which JDK is used.
You can check the current setting with the following command.
echo $JAVA_HOME
If JAVA_HOME points to a nonexistent JDK or an old JDK, Gradle may run in an unexpected environment.
Also check java -version and ./gradlew --version.
Cause 17: The Java Process Is Crashing
The Gradle Daemon runs on the Java Virtual Machine (JVM).
If the JVM itself crashes, the Gradle Daemon also stops.
If the JVM crashes, a log file with a name like the following may be generated.
hs_err_pid12345.log
If a file like this exists, the JVM itself may have terminated abnormally rather than a normal Gradle error occurring.
Cause 18: The Process Was Terminated by Android Studio or the Operating System
The Gradle Daemon may terminate when Android Studio is closed, the system is restarted, the user logs out, or memory becomes insufficient.
In particular, if the operating system as a whole is running low on memory, Gradle’s Java process may be forcibly terminated.
If the entire PC becomes slow during the build, also check memory usage and the state of other processes.
Solutions to Check First
If “Gradle build daemon has been stopped” appears and there is a problem with the build, checking the following items in order can make it easier to narrow down the cause.
- Check whether the build resumes normally after the message.
- Check whether
./gradlew --stopwas executed immediately beforehand. - Restart Android Studio.
- Stop the Gradle Daemon once.
- Run the build again.
- Check the Java version with
java -version. - Check Gradle and the JVM currently being used with
./gradlew --version. - Check the compatibility of Gradle, the Android Gradle Plugin, and the JDK.
- Check
JAVA_HOMEand the Gradle JDK in Android Studio. - Check the Daemon settings and memory settings in
gradle.properties. - Check the amount of available memory on the entire PC.
- Check whether there is a problem with the Gradle cache.
- Check whether a JVM crash log has been generated.
First Restart the Gradle Daemon
If the cause is a temporary state of the Gradle Daemon, stopping it once and starting it again may resolve the issue.
First, stop the currently running Gradle Daemons.
./gradlew --stop
After that, run the build again.
./gradlew build
A new Gradle Daemon will start as needed. Check whether the build completes normally.
Check the Status of the Gradle Daemon
Gradle allows you to check the status of running Daemons.
./gradlew --status
Using this command may allow you to check the status of currently available Daemons and stopped Daemons.
If a Daemon started with an old Gradle version or a different JDK remains, stopping it once and restarting it in the current environment can help reset the state.
Check the Gradle and JDK Combination
Check the Java version.
java -version
Next, check the JVM actually used by Gradle.
./gradlew --version
Check the displayed Gradle and JVM versions and confirm that they form a supported combination.
Check the Gradle Daemon Settings
gradle.properties may contain settings related to the Gradle Daemon.
org.gradle.daemon=false
If this setting exists, the Gradle Daemon is disabled.
In an environment where the Daemon is expected to be used, check whether this setting is intentional.
Check Gradle’s Memory Settings
If the Gradle Daemon stops during the build, also check the JVM memory settings.
org.gradle.jvmargs=-Xmx2048m
If there is insufficient memory for the size of the project, the Gradle Daemon may become unstable.
On the other hand, setting the value too high may cause the entire PC to run out of memory, so check the setting according to the amount of installed memory.
Check Detailed Errors
If another error appears before or after “Gradle build daemon has been stopped”, that message may be the actual cause.
To check a detailed stack trace, you can use the following command.
./gradlew build --stacktrace
To check more detailed logs, you can also use the following option.
./gradlew build --info
If more detailed debugging information is needed, you can also use the following command.
./gradlew build --debug
Check the Daemon Log
The Gradle Daemon log may record the process that was running immediately before the Daemon stopped.
Gradle Daemon logs are generally stored in the user’s .gradle directory.
~/.gradle/daemon/
Daemon logs may be stored in directories for each Gradle version being used.
If the build fails, check the last part of the log and confirm whether another exception occurred immediately before the Daemon stopped.
Difference Between “Gradle build daemon has been stopped” and “Gradle build daemon disappeared unexpectedly”
“Gradle build daemon has been stopped” is a message indicating that the Gradle Daemon has stopped.
It may also appear when the Daemon is stopped normally because of a configuration change or a command such as ./gradlew --stop.
On the other hand, “Gradle build daemon disappeared unexpectedly” indicates that the Daemon unexpectedly disappeared during the build.
In the latter case, there is a greater need to investigate causes of abnormal termination such as insufficient memory, a JVM crash, or forced termination by the operating system.
If only “has been stopped” is displayed and the subsequent build runs normally, it is not necessarily an error. If the build fails, also check the other error messages displayed before and after it.
Do Not Judge the Cause from the First Message Alone
“Gradle build daemon has been stopped” may not be the direct cause of the build failure, but may instead appear as a result of the Daemon being stopped by another problem.
For example, check whether errors such as the following appear immediately beforehand.
- OutOfMemoryError
- Java heap space
- Unsupported class file major version
- JVM crash
- Android Gradle Plugin compatibility errors
- Kotlin compiler errors
- External Gradle plugin errors
If these are displayed, the specific cause may be the error immediately before “Gradle build daemon has been stopped”, rather than the “Gradle build daemon has been stopped” message itself.
Summary
Android Studio’s “Gradle build daemon has been stopped” is a message displayed when the Gradle Daemon used for the build process has stopped.
It may also appear for normal reasons, such as when the Gradle Daemon is manually stopped or when Android Studio, JDK, or Gradle settings are changed.
On the other hand, if the Daemon repeatedly stops during the build, you need to check for incompatible Gradle and JDK versions, compatibility with the Android Gradle Plugin, insufficient memory, Gradle cache problems, JVM crashes, and other issues.
First stop the Gradle Daemon with ./gradlew --stop and rebuild. If the issue does not improve, check the current environment with commands such as java -version, ./gradlew --version, and ./gradlew --status.
In addition, checking the Daemon settings and memory settings in gradle.properties, the Gradle JDK in Android Studio, JAVA_HOME, Gradle/AGP/JDK compatibility, and Daemon logs in order can help efficiently narrow down the cause.
