Skip to content
Latchkey

Kotlin Multiplatform Gradle Sync Fails in CI

A Kotlin Multiplatform Gradle build failed to configure. The Kotlin Gradle plugin and Android Gradle Plugin versions are out of step, a target platform is misconfigured, or a native/expect-actual dependency could not be resolved.

What this error means

Gradle fails during configuration of a KMP module - a Kotlin/AGP compatibility error, a missing androidTarget()/iosX64() target, or an unresolved klib. The message points at the Kotlin plugin or a specific target.

Gradle output
> The Android Gradle plugin supports only Kotlin Gradle plugin version 1.9.20 and higher.
# or
> Cannot locate tasks that match ':shared:compileKotlinIosArm64' as task 'compileKotlinIosArm64' not found

Common causes

Kotlin / AGP / Gradle version mismatch

KMP is sensitive to the Kotlin Gradle plugin, AGP, and Gradle versions lining up. A mismatch fails at configuration time.

A target not configured for this build

A task references a platform target (e.g. iosArm64) that the kotlin { } block does not declare, so Gradle cannot find it.

How to fix it

Align the Kotlin/AGP/Gradle versions

Use a compatible matrix in your version catalog and the Gradle wrapper.

libs.versions.toml
# gradle/libs.versions.toml
[versions]
kotlin = "2.0.20"
agp = "8.5.2"
# ensure gradle/wrapper/gradle-wrapper.properties uses a Gradle that supports both

Declare every target you build

Make sure the kotlin { } block declares the platforms your tasks compile.

build.gradle.kts
kotlin {
  androidTarget()
  iosArm64()
  iosSimulatorArm64()
}

How to prevent it

  • Manage Kotlin/AGP versions in a single version catalog.
  • Pin the Gradle wrapper to a version compatible with your Kotlin/AGP.
  • Declare all platform targets your CI tasks compile.

Frequently asked questions

What causes "KMP Gradle sync failed"?
KMP is sensitive to the Kotlin Gradle plugin, AGP, and Gradle versions lining up. A mismatch fails at configuration time.
How do I fix KMP Gradle sync failed?
Use a compatible matrix in your version catalog and the Gradle wrapper.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card