androidfluttergradlebuilddaemon

Gradle build daemon disappeared unexpectedly when building Flutter APK on Mac M2


I’m trying to build a Flutter APK on my Mac Mini (M2, macOS Sonoma) using the latest stable Flutter version (3.35.1) and Gradle (8.12).

When I run:

flutter build apk --split-per-abi

the build fails with this error:

Daemon pid: 960
log file: /Users/bugfinder/.gradle/daemon/8.12/daemon-960.out.log
one flag when building your app.----- End of the daemon log -----

JVM crash log found: file:///Users/bugfinder/Downloads/bug-finder-project/SERVAT-APP/user-panel/servat-user/android/hs_err_pid960.log

FAILURE: Build failed with an exception.

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

My setup

Device: Mac Mini M2
OS: macOS Sonoma
Flutter: 3.35.1 (stable)
Gradle: 8.12
Java: OpenJDK 17 (installed via Homebrew)

My gradle.properties

org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true

What I tried

How can I fix the Gradle build daemon disappeared unexpectedly error when building a Flutter APK with the daemon enabled on Mac M2? Is there a recommended gradle.properties or JDK configuration for Flutter projects to avoid this JVM crash?


Solution

  • Add this line to the gradle.properties

    org.gradle.jvmargs=-Xms1024m -Xmx4096m