An Expo EAS Android build runs on an older Java than the Android Gradle plugin needs
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.Short answer
On EAS the Java version comes from the build image, not from a setting of its own. The Android Gradle plugin 8 and 9 need JDK 17, and every current image has it. If your build runs an older Java, an old image is selected in eas.json or by your SDK version; a local build uses your own JAVA_HOME instead.
Fix it fast
1Find out which cause you have
Open the failed build on expo.dev, expand the Spin up build environment phase and read the image name. It contains the JDK version, for example jdk-17 or jdk-11. If you ran eas build --local, there is no image: the build used your own machine.
grep -n -B1 -A3 '"image"' eas.json2Match what you see, then jump to its fix
- 1
eas.json has an image value naming a jdk-11 or jdk-8 image, or an alias of an old SDK such as sdk-49eas.json pins an old build imageFix - 2
eas.json has no image line, and the image in the build log is an older one with jdk-11No image is set and the project is on an old SDKFix - 3
The error appears only with eas build --local, or only on your laptopThe build runs locally with the JDK of your machineFix - 4
The android folder is committed, and its gradle.properties has an org.gradle.java.home line with a path that exists only on a developer machinegradle.properties forces a JDK path from another machineFix
- 1
What does the error look like?
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
Cause 1 of 4
eas.json pins an old build image
1Check
Some older images ship Java 11 or Java 8; the image for SDK 49, for example, uses Java 11. The images for SDK 50 and newer use Java 17. A pinned old image keeps the build on the old Java, whatever the project needs now.
grep -n "image" eas.json2Fix
Point the profile at the alias that matches your SDK, or at latest, or remove the line to let EAS choose.
{
"build": {
"production": {
"android": {
"image": "latest"
}
}
}
}3Verify
Start a new build and read the image name again in Spin up build environment; it now names jdk-17.
eas build --platform android --profile productionConfirmed by docs.expo.dev
Cause 2 of 4
No image is set and the project is on an old SDK
1Check
When image is omitted, EAS selects one from your Expo SDK version and React Native version. A project that stayed on an old SDK is given the image meant for that SDK, with the Java of that time.
grep -n '"expo"' package.json2Fix
Upgrade the Expo SDK, which is the proper fix. Until then, choose a newer image yourself, as in the first cause, and make sure the Android Gradle plugin of the project accepts it.
# use the SDK version you are moving to
npm install expo@^58.0.0
npx expo install --fix3Verify
The new build's image name contains jdk-17 and the Run gradlew phase no longer complains about the Java version.
npx expo-doctorConfirmed by docs.expo.dev
Cause 3 of 4
The build runs locally with the JDK of your machine
1Check
A local build runs on your machine with your own tools. Software versions set in eas.json are ignored, so image does nothing there. Gradle then runs on the JDK that JAVA_HOME names, or on the java found on PATH if JAVA_HOME is empty.
echo $JAVA_HOME
java -version2Fix
Install JDK 17 or newer and point JAVA_HOME at it before you start the build. On macOS the helper below finds an installed JDK 17.
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
java -version3Verify
java -version prints 17, and eas build --platform android --local gets past the plugin check.
eas build --platform android --localConfirmed by developer.android.com
Cause 4 of 4
gradle.properties forces a JDK path from another machine
1Check
Gradle looks at org.gradle.java.home first and only then at JAVA_HOME and PATH. A line committed from a developer's laptop wins over the environment of the build server.
grep -rn "org.gradle.java.home" android/gradle.properties ~/.gradle/gradle.properties 2>/dev/null2Fix
Delete that line from the committed file, so the build environment decides which JDK runs Gradle.
# android/gradle.properties: remove this line
# org.gradle.java.home=/Library/Java/JavaVirtualMachines/some-jdk/Contents/Home3Verify
Commit the change and start a new build; the log shows the Java of the image.
eas build --platform android --profile productionConfirmed by docs.gradle.org
How do I stop it coming back?
- Leave image out of eas.json unless you need a different one, and re-check it after every SDK upgrade.
- Read the JDK requirement in the Android Gradle plugin release notes before you upgrade the plugin.
- Keep machine-specific paths out of committed Gradle files.
- Run local builds with a JDK 17 JAVA_HOME, so they behave like the EAS image.
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
EAS Build fails in the Run gradlew phase with 'Gradle build failed with unknown error'
Gradle build daemon disappeared unexpectedly
The message is a wrapper: the real error sits earlier in the Run gradlew log.
4 causes, each with a fixMobile apps
Gradle ignores JAVA_HOME and starts a different JDK
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
Gradle does not read JAVA_HOME first.
3 causes, each with a fixMobile apps
Flutter Android build fails with Unsupported class file major version
Unsupported class file major version 65
The number is the Java version that tried to read a file: 61 is Java 17, 65 is Java 21.
3 causes, each with a fixMobile apps
Android app crashes because the Apache HTTP classes are missing
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
From Android 9 the Apache HTTP client is no longer on the default classpath, so code or a library that still uses org.apache.http fails at runtime.
2 causes, each with a fixMobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fix