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

Diagnose it: get the real failure out of Gradle

Gradle summarises failures aggressively, and the top-level message frequently describes a downstream symptom rather than the cause. Re-run the failing task with diagnostics before changing build logic.

Terminal
# the actual stack, plus what Gradle decided about the build
./gradlew <task> --stacktrace --info

# is a stale daemon or cache involved?
./gradlew --stop
./gradlew <task> --no-daemon --no-build-cache

# what does Gradle think the environment is?
./gradlew -version

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
}

Configuration cache and CI

  • The configuration cache rejects build logic that reads mutable state at execution time, which is why enabling it surfaces errors an existing build never showed.
  • Run with --configuration-cache-problems=warn first to see the full list rather than failing on the first one.
  • A cached configuration keyed to a different environment is worse than none. Include the JDK version in your cache key.

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 Gradle "Could not resolve org.jetbrains.kotlin:kotlin-stdlib" in CI?
There are 2 common causes: the repository serving the stdlib is not declared and a forced stdlib version conflicts with the plugin. Without mavenCentral() (or an internal mirror) in repositories {}, Gradle has nowhere to fetch the stdlib on a clean CI runner.
How do I fix Gradle "Could not resolve org.jetbrains.kotlin:kotlin-stdlib" in CI?
There are 2 fixes depending on which cause you have: declare the repository and let the plugin manage the stdlib version. Work through them in order, since the first is the most common.
What does Gradle "Could not resolve org.jetbrains.kotlin:kotlin-stdlib" in CI actually mean?
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.
How do I stop Gradle "Could not resolve org.jetbrains.kotlin:kotlin-stdlib" in CI happening again?
Keep a resolvable repository declared for every project in CI. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card