Android Studio Build Failed: JDK, Gradle or AGP Version Mismatch

Share
Ongoing Windows, macOS, Linux Updated November 13, 2026Based on 4 user reportsHow we research

Quick answer

Errors like 'Android Gradle plugin requires Java 17' or 'Unsupported class file major version' mean your JDK, Gradle and Android Gradle plugin versions do not match. Align them using the compatibility table.

Most likely fix: Set Gradle JDK to a matching version

How to fix it

Try these in order — the most common fix is first.

  1. 1. Set Gradle JDK to a matching version

    1. File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK
    2. Choose GRADLE_LOCAL_JAVA_HOME (default for new projects) or jbr-17
    3. AGP 8.x requires JDK 17; AGP 9.5 lists JDK 17 as minimum
    Did this fix it?
  2. 2. Make terminal and IDE agree

    1. Set JAVA_HOME to the same JDK the IDE uses
    2. Or set org.gradle.java.home in gradle.properties
    Did this fix it?
  3. 3. Match Gradle and AGP

    1. Check the compatibility table in the Android Gradle plugin release notes
    2. AGP 9.5 needs Gradle 9.6.0 as minimum and SDK Build Tools 36.0.0
    3. Use Tools > AGP Upgrade Assistant (or the upgrade prompt) to update safely
    4. Edit distributionUrl in gradle/wrapper/gradle-wrapper.properties if needed
    Did this fix it?
  4. 4. Align Kotlin

    1. Update the Kotlin Gradle plugin to a version that supports your AGP and Gradle
    2. If using Kotlin below 2.2, set kotlinOptions { jvmTarget = "17" } to match compileOptions
    Did this fix it?
  5. 5. Reset caches

    1. File > Invalidate Caches > Invalidate and Restart
    2. Run ./gradlew --stop and sync again
    Did this fix it?

Symptoms

Build or sync fails with messages like 'Android Gradle plugin requires Java 17 to run. You are currently using Java 11', 'Unsupported class file major version', or a Kotlin or plugin version conflict after updating Studio.

Why it happens

  • Gradle JDK older (or newer) than AGP supports
  • Terminal builds use JAVA_HOME while the IDE uses a different JDK
  • Gradle version below what the AGP requires
  • Kotlin Gradle plugin version incompatible with AGP or Gradle
  • Updating Android Studio without updating the project

This guide also covers

  • android gradle plugin requires java 17
  • unsupported class file major version android studio
  • android studio kotlin version mismatch
  • agp gradle compatibility

Still not working?

If Android Studio keeps failing, you're not alone. See every Android Studio problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

Other Android Studio errors

All 11 Android Studio errors and fixes →