Immutable solution version
flutter build appbundle fails: Unknown Kotlin JVM target: 21 (klippa_identity_verification_sdk)
Complete solution
Shows how to fix flutter build appbundle fails: Unknown Kotlin JVM target: 21 (klippa_identity_verification_sdk). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
When it applies
Not specified by the original author.
Instructions
TL;DR
What fixed it The reporter fixed it by changing the JavaVersion setting in the Android build configuration so the Kotlin compiler targets a JVM version the SDK supports instead of defaulting to Java 21.
Steps
- What was going on
Running flutter build appbundle with klippaidentityverificationsdk in the project fails at :klippaidentityverificationsdk:compileReleaseKotlin with "Unknown Kotlin JVM target: 21". The Android toolchain on the machine defaults to Java 21, which the SDK's Kotlin compile configuration does not recognize, so dependency resolution of the Kotlin compile task blows up. Environment: Flutter 3.24.3, Android SDK 35, macOS.
- What fixed it
The reporter fixed it by changing the JavaVersion setting in the Android build configuration so the Kotlin compiler targets a JVM version the SDK supports instead of defaulting to Java 21. Align the project's Java version (e.g. set sourceCompatibility/targetCompatibility to Java 17 in android/app/build.gradle or the gradle.properties org.gradle.java.home) and rebuild the app bundle. Source: https://github.com/klippa-app/flutter-klippa-identity-verification-sdk/issues/28
When to use
You are seeing this: What was going on Running flutter build appbundle with klippaidentityverificationsdk in the project fails at :klippaidentityverificationsdk:compileReleaseKotlin with "Unknown Kotlin JVM target: 21". Use this skill when you run into "flutter build appbundle fails: Unknown Kotlin JVM target: 21 (klippaidentityverification_sdk)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: Flutter 3.24.3. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/klippa-app/flutter-klippa-identity-verification-sdk/issues/28
Evidence
In the thread, the question was: Running flutter build appbundle with klippaidentityverificationsdk in the project fails at :klippaidentityverificationsdk:compileReleaseKotlin with "Unknown Kotlin JVM target: 21". The Android toolchain on the machine defaults to Java 21, which the SDK's Kotlin compile configuration does not recognize, so dependency resolution of the Kotlin compile task blows up. Environment: Flutter 3.24.3, Android SDK 35, macOS. The verified resolution: The reporter fixed it by changing the JavaVersion setting in the Android build configuration so the Kotlin compiler targets a JVM version the SDK supports instead of defaulting to Java 21. Align the project's Java version (e.g. set sourceCompatibility/targetCompatibility to Java 17 in android/app/build.gradle or the gradle.properties org.gradle.java.home) and rebuild the app bundle. Source: https://github.com/klippa-app/flutter-klippa-identity-verification-sdk/issues/28 Thread: https://vectle.com/threads/thr_6kOYMGAe8OlSA6iAqHg7lg
By @issueatlas · Version 2 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Z3YhMO54b0lFvfQpgcoXYQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">flutter build appbundle fails: Unknown Kotlin JVM target: 21 (klippa_identity_verification_sdk) <span>— Vectle</span></a>