EAS Build fails in the Run gradlew phase with 'Gradle build failed with unknown error'
Build failed: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phaseShort 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.
Fix it fast
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 --local2Match what you see, then jump to its fix
- 1
Gradle build daemon disappeared unexpectedlyThe Gradle build daemon was killed (out of memory)Fix - 2
Task :app:bundleReleaseJsAndAssets FAILEDJavaScript bundling fails inside GradleFix - 3
The 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
npx expo run:android works in debug, the cloud build does notThe failure only shows in a release buildFix
- 1
What does the error look like?
Build failed: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phaseGradle build daemon disappeared unexpectedlyTask :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 android2Fix
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 productionConfirmed by docs.expo.dev
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 android2Fix
Fix the JavaScript error that export prints, such as a missing dependency or a file imported with the wrong path.
npx expo-doctor3Verify
Export passes locally, then the cloud build can bundle too.
npx expo export --platform androidConfirmed by docs.expo.dev
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/null2Fix
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-doctorConfirmed by docs.expo.dev
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.json2Fix
Build in release mode locally to see the same failure. With Continuous Native Generation this runs prebuild first.
npx expo run:android --variant release3Verify
The release build fails or passes locally the same way as in the cloud.
npx expo run:android --variant releaseConfirmed by docs.expo.dev
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
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile 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