Skip to content
Latchkey

Kotlin/Gradle "Unsupported class file major version" in CI

Each JDK reads bytecode up to a fixed class-file major version (52 = Java 8, 55 = 11, 61 = 17, 65 = 21). "Unsupported class file major version NN" means Gradle or a plugin is running on an older JDK than the bytecode it is asked to read on the runner.

What this error means

Configuration or a task fails with "Unsupported class file major version 65" (or 61, 55), often thrown from ASM inside a Gradle plugin.

Gradle
> Could not create task ':app:compileKotlin'.
> Unsupported class file major version 65

Common causes

Gradle runs on an older JDK than a dependency needs

A dependency or plugin compiled for Java 21 (major 65) is read by a Gradle JVM on Java 17, which cannot parse it.

The runner default JDK is too old

setup-java (or the image) provides an older JDK than the project bytecode target, so class parsing fails.

How to fix it

Run Gradle on a matching JDK

Provision a JDK new enough for the bytecode with setup-java before the Gradle step.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: 'temurin'
    java-version: '21'

Align the build target with the runner JDK

  1. Decode the major version (65 -> Java 21, 61 -> 17, 55 -> 11).
  2. Set a JDK toolchain matching what your dependencies require.
  3. Ensure the Gradle daemon uses that JDK, not an older system default.
build.gradle.kts
kotlin { jvmToolchain(21) }

How to prevent it

  • Pin the CI JDK with setup-java to match the highest bytecode used.
  • Use a Gradle/Kotlin toolchain so the target JDK is explicit.
  • Upgrade the Gradle JVM when adopting dependencies built for newer Java.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →