Maaz Zindani

Loading the index…

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

Android Studio or IntelliJ rejects the JDK chosen for Gradle

ErrorInvalid Gradle JDK configuration found.

Short answer

The IDE could not use the JDK saved for this project's Gradle runs. Either the saved path no longer exists, or the JDK's version does not suit Gradle or the Android Gradle plugin. Open the Gradle settings and pick a JDK that is installed and in range.

  • Applies to Android Studio current stable, IntelliJ IDEA current stable, Gradle 8.x and 9.x, Android Gradle plugin 8.x and 9.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See which JDK the project has saved and which one the build really starts with.

    grep -n gradleJvm .idea/gradle.xml
    ./gradlew --version
  2. 2Match what you see, then jump to its fix

    1. 1gradleJvm names a JDK you removed, upgraded or that came from another computerThe saved JDK path no longer existsFix
    2. 2The IDE shows a different JDK from the one you chose, or the path in the message does not existgradle.properties forces a bad JDKFix
    3. 3Sync fails right after a JDK upgrade, or the plugin asks for Java 17The JDK is outside the range your Gradle and plugin supportFix

What does the error look like?

  • Invalid Gradle JDK configuration found.
  • Android Gradle plugin requires Java 17 to run. You are currently using Java 11.

Cause 1 of 3

The saved JDK path no longer exists

1Check

The choice is stored per project in .idea/gradle.xml. A project copied from a colleague or an old machine keeps a name that is missing here.

grep -n gradleJvm .idea/gradle.xml

2Fix

Open Settings, then Build, Execution, Deployment, then Build Tools, then Gradle, and pick a Gradle JDK from the list. GRADLE_LOCAL_JAVA_HOME is the recommended macro for new projects.

# Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK

3Verify

Sync the project. The warning disappears.

./gradlew help

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

gradle.properties forces a bad JDK

1Check

IntelliJ checks org.gradle.java.home in gradle.properties first, then JAVA_HOME, when it picks the Gradle JVM for an existing project.

grep -rn "org.gradle.java.home" gradle.properties ~/.gradle/gradle.properties
echo $JAVA_HOME

2Fix

Point it at a JDK that exists, or delete the line so the IDE setting applies.

# gradle.properties
org.gradle.java.home=/path/to/jdk-17

3Verify

Restart the Gradle daemon and sync.

./gradlew --stop && ./gradlew help

Confirmed by jetbrains.com

Did this fix it?

Cause 3 of 3

The JDK is outside the range your Gradle and plugin support

1Check

Gradle 9 runs on Java 17 to 27 and the Android Gradle plugin 9.5 needs JDK 17. A newer JDK also needs a new enough Gradle: Java 25 needs Gradle 9.1.0 or later.

grep distributionUrl gradle/wrapper/gradle-wrapper.properties

2Fix

Choose a JDK in range, such as 17 or 21, or raise the wrapper version to one that supports your JDK.

./gradlew wrapper --gradle-version 9.9.1

3Verify

The JVM line in the version output is in range.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Prefer GRADLE_LOCAL_JAVA_HOME or Gradle daemon JVM criteria over an absolute JDK path in shared files.
  • Keep .idea/gradle.xml out of version control if it holds machine paths.
  • Check the compatibility table before moving to a new JDK.

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.