Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Flutter and app store releases · Comparison

The Android build stops because the JDK it uses has no jlink

Short answer

jlink executable .../bin/jlink does not exist. means the Android Gradle plugin needed jlink, from the JDK that compiles your code, to build its JDK image for Java 9+ sources, and the installation named in the path has none. Point the IDE's Gradle JDK, JAVA_HOME or org.gradle.java.home at a full JDK 17+, then stop the daemons. AGP 8.x to 9.5.2.

  • Applies to Android Gradle plugin 8.x to 9.5.2, Gradle 8.14 to 9.9.2, JDK 17+, Android Studio and IntelliJ IDEA with Gradle-based Android projects
  • Updated
  • By Maaz Zindani, Senior Software Engineer

The Android Gradle plugin needs jlink, a tool shipped only in a full JDK, to build a trimmed JDK image for modules whose Java source level is 9 or higher. When the installation Gradle runs on has no bin/jlink, the build stops with a message naming the exact path that lacks it. The fix is to run Gradle on a complete JDK 17 or newer.

The real question is which setting chose the bad installation, because a Gradle build can get its JDK from several places and your IDE and your terminal may not agree. The table lists them in the order to check.

At a glance

Several places can name the JDK; the one that matches the path in your error message is the one to fix.
Where the JDK is chosenUsed byHow to see itHow to change it
Gradle JDK setting in Android Studio or IntelliJBuilds started with the IDE's buttons and syncsThe folder in the error message, compared with the setting under Gradle in the build tools settingsPick a full JDK 17+ from the drop-down, or a downloaded one
JAVA_HOME, or java on the PATHBuilds typed in a terminal and most CI runs`echo "$JAVA_HOME"` and `ls "$JAVA_HOME/bin/jlink"`Export JAVA_HOME in the shell profile or the CI configuration
org.gradle.java.home in gradle.propertiesEvery build that reads that file, project or user level`grep -n org.gradle.java.home gradle.properties ~/.gradle/gradle.properties`Edit the value, or delete the line
A Java toolchain declared in build filesCompilation tasks, as Gradle's toolchain feature selects them`./gradlew -q javaToolchains`Declare a toolchain and a resolver; check that Is JDK says true

Start from the path in the message

The error prints the folder it looked in. Copy that folder, list its bin directory and see what is there. A runtime-only install has java but no javac or jlink.

What is in that installation, and what Gradle can see

ls "<folder-from-the-message>/bin" | grep -E "^(java|javac|jlink)"
./gradlew -q javaToolchains

The IDE and the terminal can disagree

When you press the IDE's build button, its own Gradle JDK setting decides which JDK starts Gradle. In a terminal, ./gradlew follows JAVA_HOME instead. A project that builds in one and fails in the other has two different installations, one of them incomplete. Android's documentation on Java versions covers the Gradle JDK setting and the macro that new projects use.

Making both point at the same full JDK removes the whole class of surprise.

After you change anything, stop the daemons

Gradle keeps a daemon running between builds, and that daemon was started with the old JDK. Changing the setting without stopping it can leave you looking at the same error.

Stop old daemons, then rebuild

./gradlew --stop
./gradlew :app:compileDebugJavaWithJavac

A value copied from another machine

org.gradle.java.home is easy to inherit by accident: a path from a colleague's computer, or from a JDK you since uninstalled, committed into the project's gradle.properties. Keep machine-specific paths in the properties file in your Gradle user home instead, so the project itself stays portable.

jlink runs and the build passes

  • "$JAVA_HOME/bin/jlink" --version prints a version.
  • ./gradlew -q javaToolchains shows Is JDK: true for the entries you rely on.
  • The build passes the JDK image step and moves on to compiling.

If the message names javac or jmod instead of jlink, the plugin ran the same check on another tool of that JDK, and a full JDK fixes it the same way.

Which to pick

  • jlink exists only in a full JDK; use 17 or newer for current AGP.
  • Match the path in the error to the setting that chose it.
  • Run ./gradlew --stop after each change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. 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.

Next step

Want a second pair of eyes on it?

Send me the error and what changed before it started. I reply within 24 hours.