Maaz Zindani

Loading the index…

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

EAS Build fails in the Run gradlew phase with 'Gradle build failed with unknown error'

ErrorBuild failed: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase

Short answer

The message is a wrapper: the real error sits earlier in the Run gradlew log. Expand the first failed phase on the build page. Then match it: a Gradle daemon that disappeared means memory (use a larger resource class), a bundleReleaseJsAndAssets failure is a JavaScript error, anything else is usually versions or files missing from the upload.

  • Applies to EAS CLI current, Expo SDK 5x, Android
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the failed build page, expand the Run gradlew phase and search the log for 'FAILED' and 'What went wrong'. Then reproduce the same Gradle step on your machine.

    eas build --platform android --local
  2. 2Match what you see, then jump to its fix

    1. 1Gradle build daemon disappeared unexpectedlyThe Gradle build daemon was killed (out of memory)Fix
    2. 2Task :app:bundleReleaseJsAndAssets FAILEDJavaScript bundling fails inside GradleFix
    3. 3The first failed line mentions a tool version, an undefined value, or a file that exists on your machineVersion mismatch, missing env value or a file left out of the uploadFix
    4. 4npx expo run:android works in debug, the cloud build does notThe failure only shows in a release buildFix

What does the error look like?

  • Build failed: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase
  • Gradle build daemon disappeared unexpectedly
  • Task :app:bundleReleaseJsAndAssets FAILED

Cause 1 of 4

The Gradle build daemon was killed (out of memory)

1Check

Expo's troubleshooting guide says this usually means the Node.js bundling process was killed, often by memory limits.

npx expo export --platform android

2Fix

Use the large resource class for the Android profile in eas.json (it is not available on the free plan), and reduce the bundle size. Expo suggests Expo Atlas for finding what makes it large.

{
  "build": {
    "production": {
      "android": { "resourceClass": "large" }
    }
  }
}

3Verify

Start the build again and watch the Run gradlew phase finish.

eas build --platform android --profile production

Confirmed by docs.expo.dev

Did this fix it?

Cause 2 of 4

JavaScript bundling fails inside Gradle

1Check

The bundling step runs Metro. A syntax error, a missing import or an unresolved module makes it fail, and local export shows the error faster.

npx expo export --platform android

2Fix

Fix the JavaScript error that export prints, such as a missing dependency or a file imported with the wrong path.

npx expo-doctor

3Verify

Export passes locally, then the cloud build can bundle too.

npx expo export --platform android

Confirmed by docs.expo.dev

Did this fix it?

Cause 3 of 4

Version mismatch, missing env value or a file left out of the upload

1Check

The guide lists mismatched tool versions, missing environment variables and files excluded by .gitignore or .easignore as common causes. expo-doctor checks dependency compatibility.

npx expo-doctor
cat .gitignore .easignore 2>/dev/null

2Fix

Update the packages doctor flags. Put any non-secret build variable in the env block of the profile in eas.json, and take needed files out of .gitignore and .easignore.

{
  "build": {
    "production": {
      "env": { "API_URL": "https://api.example.com" }
    }
  }
}

3Verify

Run the doctor again, then rebuild.

npx expo-doctor

Confirmed by docs.expo.dev

Did this fix it?

Cause 4 of 4

The failure only shows in a release build

1Check

EAS runs ./gradlew with :app:bundleRelease by default, so it builds a release, not a debug build.

grep -n gradleCommand eas.json

2Fix

Build in release mode locally to see the same failure. With Continuous Native Generation this runs prebuild first.

npx expo run:android --variant release

3Verify

The release build fails or passes locally the same way as in the cloud.

npx expo run:android --variant release

Confirmed by docs.expo.dev

Did this fix it?

How do I stop it coming back?

  • Run npx expo-doctor and a local release build before every store build.
  • Keep the tool versions on your machine in line with what the build uses, as mismatched versions are a listed cause.
  • Do not set gradleCommand unless you need a task that the buildType option cannot do.
  • Compare a failed build to the last good one with the Compare button on the build page.

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

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

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.