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.
> 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 modeDiagnose 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.
# 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 -versionCommon 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
- Ensure
mavenCentral()(or your mirror) is inrepositories {}. - Remove
--offlineif the runner has no populated cache. - Re-run resolution to fetch the stdlib.
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.
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=warnfirst 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.