Unsupported class file major version Android Origin: On your device OSI layer 7 · Application Last updated 14 Oct 2026

Gradle: Unsupported class file major version / Android Gradle plugin requires Java 17 to run

The JDK running Gradle doesn’t match what the Gradle version or Android Gradle Plugin (AGP) supports.

Exact message you may see Unsupported class file major versionAndroid Gradle plugin requires Java 17 to runUnsupported JavaIncompatible Gradle JVM
Seen on: Android Java

Meaning

AGP 8.x requires JDK 17+, while old Gradle versions can’t run on new JDKs (“Unsupported class file major version 65” = JDK 21 on an old Gradle). Android Studio’s Gradle JDK setting, JAVA_HOME and CI images often disagree.

Common causes

  • AGP 8 with JDK 11 (“requires Java 17”)
  • Old Gradle wrapper with JDK 21+ (major version 65)
  • CI image JDK differs from Android Studio’s embedded JDK
  • JAVA_HOME pointing to a different JDK than Studio

⚡ Quick fix

  1. Settings → Build Tools → Gradle → Gradle JDK: select JDK 17 (embedded JBR)
  2. Upgrade the Gradle wrapper for newer JDKs
  3. Set JAVA_HOME / setup-java to 17 in CI

Detailed fix by platform

Android

  1. Check and upgrade the wrapper:
    bash
    ./gradlew --version                   # shows Gradle version and the JVM it runs on
    ./gradlew wrapper --gradle-version 8.7
    # GitHub Actions:
    # - uses: actions/setup-java@v4
    #   with: { distribution: temurin, java-version: '17' }

How to diagnose

  1. JVM — Which JDK runs Gradle (gradlew --version)?
  2. Versions — AGP ↔ Gradle ↔ JDK compatibility
  3. Environment — Studio vs CLI vs CI differences

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Android resource linking failed — AAPT: error: resource x (aka y) not found — Android resource linking failed (Android)Android resource link…android:attr/lStar not found — AAPT: error: resource android:attr/lStar not found (Android)android:attr/lStar no…ClassNotFoundException — java.lang.ClassNotFoundException / NoClassDefFoundError (Java)ClassNotFoundExceptionCould not resolve — Gradle: Could not resolve all files for configuration / Could not resolve dependency (Android)Could not resolveDependency requires compileSdk 34 or later — Android Gradle: Execution failed for task ':app:checkDebugAarMetadata'. Dependency requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs (Flutter / Dart)Dependency requires c…Duplicate class — Duplicate class X found in modules A and B (Android)Duplicate classGradle task assembleDebug failed with exit code 1 — Flutter: Exception: Gradle task assembleDebug failed with exit code 1 (Flutter / Dart)Gradle task assembleD…Gradle wrapper main class — Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain (Java)Gradle wrapper main c…Unsupport…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.