Skip to content
Latchkey

Gradle "Could not resolve org.jetbrains.kotlin:kotlin-stdlib" in CI

The Kotlin plugin adds kotlin-stdlib for you. A "Could not resolve" error means Gradle cannot fetch the requested stdlib version: mavenCentral is missing from repositories, the runner has no network to it, or a forced version conflicts with the plugin version.

What this error means

Dependency resolution fails with "Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.9.25" (or a "Conflict(s) found for the following module") pointing at the stdlib.

Gradle
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib:2.0.21.
  Required by:
      project :app
  > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:2.0.21.
    > No cached version available for offline mode

Common causes

The repository serving the stdlib is not declared

Without mavenCentral() (or an internal mirror) in repositories {}, Gradle has nowhere to fetch the stdlib on a clean CI runner.

A forced stdlib version conflicts with the plugin

A resolution rule or BOM forces a stdlib version different from what the Kotlin plugin expects, so Gradle cannot agree on one.

How to fix it

Declare the repository

  1. Ensure mavenCentral() (or your mirror) is in repositories {}.
  2. Remove --offline if the runner has no populated cache.
  3. Re-run resolution to fetch the stdlib.
build.gradle.kts
repositories {
    mavenCentral()
}

Let the plugin manage the stdlib version

Do not force a stdlib version; align it with the Kotlin plugin so the two never conflict.

build.gradle.kts
dependencies {
    // no explicit kotlin-stdlib pin; the kotlin("jvm") plugin adds the matching version
}

How to prevent it

  • Keep a resolvable repository declared for every project in CI.
  • Avoid forcing kotlin-stdlib; let the plugin choose the matching version.
  • Cache the Gradle dependency cache so offline resolution has the stdlib available.

Frequently asked questions

What causes ""Could not resolve ... kotlin-stdlib""?
Without mavenCentral() (or an internal mirror) in repositories {}, Gradle has nowhere to fetch the stdlib on a clean CI runner.
How do I fix "Could not resolve ... kotlin-stdlib"?
Declare the repository

Related guides

References

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