Maaz Zindani

Loading the index…

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

An Expo EAS Android build runs on an older Java than the Android Gradle plugin needs

ErrorAndroid 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.

  • Applies to Expo SDK 54 and newer, EAS CLI current, Android Gradle plugin 8.x and 9.x, JDK 17
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.json
  2. 2Match what you see, then jump to its fix

    1. 1eas.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. 2eas.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. 3The error appears only with eas build --local, or only on your laptopThe build runs locally with the JDK of your machineFix
    4. 4The 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

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.json

2Fix

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 production

Confirmed by docs.expo.dev

Did this fix it?

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.json

2Fix

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 --fix

3Verify

The new build's image name contains jdk-17 and the Run gradlew phase no longer complains about the Java version.

npx expo-doctor

Confirmed by docs.expo.dev

Did this fix it?

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 -version

2Fix

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 -version

3Verify

java -version prints 17, and eas build --platform android --local gets past the plugin check.

eas build --platform android --local

Confirmed by developer.android.com

Did this fix it?

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/null

2Fix

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/Home

3Verify

Commit the change and start a new build; the log shows the Java of the image.

eas build --platform android --profile production

Confirmed by docs.gradle.org

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.