Cannot inline bytecode built with JVM target ...
The “Cannot inline bytecode built with JVM target” error means a Kotlin inline function and its call site were compiled targeting different JVM versions.
What It Means
Inline functions in Kotlin are expanded at the call site by copying their bytecode. When the caller and the callee were compiled targeting different JVM versions, the bytecode structures (class file format, method signatures) may be incompatible. The Kotlin compiler detects this mismatch and refuses to inline, showing the JVM targets of both sides.
Why It Happens
- Your project uses
jvmTarget = "1.8"but a dependency was compiled withjvmTarget = "17". - Different Gradle modules in a multi-module project have different
jvmTargetvalues. - You upgraded your JDK but didn’t update
jvmTargetinbuild.gradle.kts. - A library (e.g., Kotlinx coroutines) was compiled with a newer JVM target than your project.
- The Kotlin compiler version differs between modules or dependencies.
How to Fix It
1. Set a consistent jvmTarget across all modules
// In each module's build.gradle.kts:
kotlin {
jvmToolchain(17)
// or
jvmTarget = "17"
}2. Set it globally in the root project
// In root build.gradle.kts — applies to all subprojects:
subprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
}3. Use Java toolchains to auto-detect the JDK
// build.gradle.kts
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}4. Check your Kotlin compiler version
// build.gradle.kts — ensure all modules use the same Kotlin version
plugins {
kotlin("jvm") version "2.0.0" // same version everywhere
}
// Check the wrapper
// gradle-wrapper.properties: kotlin.version must match5. Clean and rebuild after changing targets
# Clear all cached bytecode and recompile
./gradlew clean buildIf you use IntelliJ, also invalidate caches: File → Invalidate Caches and Restart.
6. Check transitive dependencies
Some libraries publish artifacts compiled with different JVM targets. Examine your dependency tree:
./gradlew dependenciesIf a dependency is compiled for JVM 1.8 and your project targets JVM 17, the inline function from that dependency will trigger this error. In that case, update the dependency to a version compiled for your JVM target.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro