How to fix

How to fix "Gradle build daemon disappeared unexpectedly" in React Native & Expo

Leader posted Originally published at dev.to 2 min read

If you’ve been building mobile apps with React Native or Expo long enough, you’ve definitely hit that brick wall where a standard debug build works perfectly, but the moment you run eas build or try to compile a production AAB/APK for the Play Store, the terminal throws a generic, frustrating crash:

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

What makes this error so frustrating is that the terminal output rarely tells you why the daemon vanished.

The Root Cause: Out-of-Memory (OOM)

When you trigger a release build, the Node process responsible for bundling your JavaScript files, assets, and third-party native modules spikes heavily in memory. By default, Android's JVM (Java Virtual Machine) doesn't allocate enough heap space to handle these massive compilation steps for modern, dependency-heavy apps.

When the local or CI machine hits its limit, it forcefully kills the Gradle daemon to protect system stability.

The 3-Step Surgical Fix

Instead of blindly deleting your .gradle cache or reinstalling Android Studio, you can resolve this permanently by updating your configuration parameters.

1. Allocate More Heap Space

Navigate to your project's android/gradle.properties file and look for or append the org.gradle.jvmargs line. Increase the maximum heap size (-Xmx) to at least 4GB or 8GB depending on your app size:

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
2. Configure EAS Build (If using Expo)

If you are running your builds via Expo Application Services (EAS), you need to tell the remote builders to utilize a larger resource class. Open your eas.json file and specify a larger builder instance under your production profile:

{
  "build": {
    "production": {
      "android": {
        "resourceClass": "large"
      }
    }
  }
}
3. Clear and Reset

Once the files are saved, kill any lingering zombie daemons and clear the old build artifacts so Gradle can start fresh:

cd android
./gradlew clean
./gradlew cleanBuildCache

Taming the rest of your terminal logs

Native Android and iOS build logs can easily stretch to hundreds of lines of total noise, hiding the true dependency mismatch.

If you are currently fighting a different native module error or a breaking CocoaPods mismatch, I built a free developer utility called FixMyError that parses raw terminal dumps instantly. It strips out the conversational AI fluff and gives you the exact surgical terminal command or config change needed to unblock your build layout in 3 seconds.

Give it a spin if you are currently stuck: Try FixMyError Free

Let me know in the comments if increasing the JVM heap size successfully unblocked your production build!

2 Comments

0 votes
0

More Posts

React Native Quote Audit - USA

kajolshah - Mar 2

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Why React Native Builds Break After Updating Dependencies (And How to Fix It)

Asta Silva - Apr 19

React Native Android Autolinking Issues: Common Problems and What to Check

Asta Silva - Apr 6

React Native Android Build Failed: Could Not Resolve Dependency (Real Causes)

Asta Silva - Apr 13
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!