kmp-gradle-version-catalog
Use when adding, upgrading or auditing dependencies and Gradle plugins in a Kotlin Multiplatform project - libs.versions.toml, [versions] [libraries] [plugins] [bundles], catalog entries for Room 3 (androidx.room3), the Koin compiler plugin or com.android.kotlin.multiplatform.lib
Install
npx skills add https://github.com/Kushpawan/kmp-mobile-skills/tree/main/skills/kmp-gradle-version-catalog
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kushpawan-kmp-mobile-skills@llmmart
git clone https://github.com/Kushpawan/kmp-mobile-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole kushpawan/kmp-mobile-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
KMP Gradle version catalog and dependencies
Every version lives in exactly one version catalog, every dependency lands in the narrowest source
set that needs it, and nothing goes into commonMain until you have confirmed it publishes iOS
variants. This skill edits the catalog; deciding which Kotlin, Compose Multiplatform, AGP, Gradle,
JDK and Xcode versions go together is kmp-toolchain-upgrade.
When to use
- Adding a library or Gradle plugin, or a bundle of them.
- "Could not resolve", "No matching variant" or a Kotlin metadata/ABI version error after adding one.
- Writing catalog entries for Room 3, the Koin compiler plugin or the Android-KMP library plugin.
- Changing a version key, including
kotlin(then also check Xcode, Workflow B). - Several repositories should share one catalog, or their versions have drifted.
- Extracting repeated build configuration into convention plugins.
- Developing a library locally while an app consumes it.
When not to use
- Planning a Kotlin, Compose Multiplatform, AGP, Gradle, JDK or Xcode upgrade, or asking which of
those versions work together:
kmp-toolchain-upgrade. - Creating the module that will use the dependency:
kmp-feature-module. - Writing the platform abstraction around an Android-only library:
kmp-expect-actual. - Room or Koin code and setup beyond the catalog lines:
kmp-room-database,kmp-koin-di. - Migrating a project to AGP 9 as a whole: the AGP 9 migration skill in Kotlin/kotlin-agent-skills.
- A failing build you have not yet diagnosed:
kmp-build-failure-triagein this repo.
Step 0 — Read the project first
ls gradle/libs.versions.toml 2>/dev/null # default catalog location
grep -nE 'versionCatalogs|from\(|includeBuild|dependencySubstitution|repositoriesMode' settings.gradle.kts
cat .gitmodules 2>/dev/null # catalog shared as a submodule?
ls build-logic buildSrc 2>/dev/null # convention plugins
grep -nE '^(kotlin|agp|composeMultiplatform|compose-multiplatform|ksp|room3?|koin[A-Za-z-]*)\s*=' gradle/libs.versions.toml
grep -nE 'com\.android\.(application|library|kotlin\.multiplatform\.library)|androidx\.room3?|insert-koin' gradle/libs.versions.toml
grep -rnE '"[A-Za-z0-9_.-]+:[A-Za-z0-9_.-]+:[0-9]' --include='*.gradle.kts' . | grep -v /build/ | head
xcodebuild -version 2>/dev/null | head -1 # macOS only: Xcode paired with Kotlin
| Record | Why |
|---|---|
Catalog path: gradle/libs.versions.toml, a file imported in settings.gradle.kts, or a published group:artifact:version |
Edit the real source of truth, not a copy |
Alias style: ktor-client-core (accessor libs.ktor.client.core) or camelCase |
New entries match existing ones |
Version key style: kotlinx-coroutines vs kotlinxCoroutines |
Same |
| Kotlin, AGP, Compose Multiplatform, KSP, Gradle versions, and the local/CI Xcode | Decide compatibility before choosing a library version |
Android plugins in use: com.android.kotlin.multiplatform.library or the legacy com.android.library / com.android.application in KMP modules |
New entries follow the project's plugin; do not migrate as a side effect |
Room 2 (androidx.room) or Room 3 (androidx.room3); Koin with or without its compiler plugin |
Keep the existing generation unless the user asks to move |
| Convention plugins | Shared config belongs there, not copied into modules |
includeBuild + substitution flags |
Local-library mode exists; know its property names |
| Existing hardcoded versions in build files | Report them; do not add more |
Workflow A — Add a dependency
Confirm the targets. For anything going into
commonMain, confirm iOS variants exist: search klibs.io, read the library's docs, or check Maven Central for per-target artifacts (<artifact>-iosarm64,<artifact>-iossimulatorarm64):G=io/ktor A=ktor-client-core for t in iosarm64 iossimulatorarm64; do printf '%-18s %s\n' "$t" "$(curl -s -o /dev/null -w '%{http_code}' \ "https://repo1.maven.org/maven2/$G/$A-$t/maven-metadata.xml")" done # 200 = published; androidx artifacts live on Google Maven insteadNo iOS variant means the library is Android-only: put it in
androidMainbehind an interface (kmp-expect-actual). Done when you know which source set it belongs in.Optional lookups, when the user has them installed — never required:
- JetBrains' Kotlin Multiplatform Libraries Expert skill (or the klibs.io MCP server, see klibs.io/ai) for KMP target support and latest stable coordinates.
- The Android CLI's
android studio version-lookupfor the latest versions of Maven artifacts, Android versions and SDK tools. It connects to a running Android Studio; check its arguments withandroid studio version-lookup --help. Gate oncommand -v android. See Google'sandroid-cliskill.
Confirm the Kotlin version. A library compiled by a newer Kotlin than the project's can fail with a metadata or ABI version error, especially on Kotlin/Native. Read its release notes for the Kotlin it was built with. Kotlin compiler plugins (Compose compiler, serialization, the Koin compiler plugin, SKIE) support a bounded Kotlin range — check theirs too. Done when the chosen version supports the project's Kotlin.
Add catalog entries. One
[versions]key per version family,version.refeverywhere, aliases in the file's existing style. Pin an exact stable version taken from the library's releases page; never+,latest.releaseor a range unless the project already uses rich versions. Entry forms, naming rules, BOMs and rich versions are in references/catalog-syntax.md.[versions] ktor = "<exact version>" [libraries] ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } [bundles] ktor-common = ["ktor-client-core", "ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"]Wire it into the narrowest source set.
kotlin { sourceSets { commonMain.dependencies { implementation(libs.bundles.ktor.common) } androidMain.dependencies { implementation(libs.ktor.client.okhttp) } // engine per platform iosMain.dependencies { implementation(libs.ktor.client.darwin) } commonTest.dependencies { implementation(libs.ktor.client.mock) } } }Use
apionly when the dependency's types appear in this module's public API (and therefore in an iOSexport). Done when the module compiles for every target (Verify).Plugins. Add a
[plugins]entry, declare it once in the rootbuild.gradle.ktswithalias(libs.plugins.x) apply false, thenalias(libs.plugins.x)in the module. Catalog plugin aliases cannot be used insettings.gradle.kts.Annotation processors (KSP). KMP needs one configuration per target, for example
add("kspAndroid", libs.androidx.room3.compiler),add("kspIosArm64", …),add("kspIosSimulatorArm64", …), andkspIosX64if that target exists. A missing target either fails that target's compilation or, for processors whose output is looked up at runtime, fails only when the app runs on that platform. Done when every declared target has a line.
Catalog entries for Room 3, Koin and the Android-KMP plugin
Add only the entries the project needs, in its own alias style. Versions: the latest stable from each project's release notes (or the lookups above).
[versions]
agp = "<exact version>"
room3 = "<exact version>" # Room 3 line; Room 2 uses the separate androidx.room group
sqlite = "<exact version>"
koin = "<exact version>"
koin-plugin = "<exact version>" # own release line; not managed by koin-bom
[libraries]
androidx-room3-runtime = { module = "androidx.room3:room3-runtime", version.ref = "room3" }
androidx-room3-compiler = { module = "androidx.room3:room3-compiler", version.ref = "room3" }
androidx-sqlite-bundled = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" }
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin" }
koin-core = { module = "io.insert-koin:koin-core" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
androidx-room3 = { id = "androidx.room3", version.ref = "room3" }
koin-compiler = { id = "io.insert-koin.compiler.plugin", version.ref = "koin-plugin" }
| Entry | Rule |
|---|---|
com.android.kotlin.multiplatform.library |
Ships with AGP: version.ref = "agp". Shared KMP modules apply it; com.android.application goes only in the pure-Android app module (for example :androidApp). Under AGP 9 the KMP plugin no longer works with com.android.application or com.android.library in the same module, and Kotlin 2.5 warns on every AGP version. Moving a project over is the AGP 9 migration skill, not a catalog edit |
Room 3 (androidx.room3) |
KSP only, one ksp<Target> line per target; needs a SQLiteDriver (sqlite-bundled); publishes no iosx64 artifacts. Never keep androidx.room and androidx.room3 side by side; moving from Room 2 is kmp-room-database |
| Koin compiler plugin | Separate koin-plugin key, never version.ref = "kotlin" and not covered by the BOM. It is a Kotlin compiler plugin with its own supported Kotlin range: read its release notes before bumping either. Setup: kmp-koin-di |
| build-logic needs a plugin as a library | com.android.tools.build:gradle (agp), androidx.room3:room3-gradle-plugin (room3), io.insert-koin:koin-compiler-gradle-plugin (koin-plugin), as compileOnly — see references/convention-plugins.md |
Workflow B — Bump a version key
Change one key per commit and run the full Verify after each.
- A library or its BOM: bump the one
[versions]key; read the release notes for the Kotlin it needs (Workflow A step 2). Done when Verify passes. kotlin,agp,composeMultiplatform,kspor the Gradle wrapper: these depend on each other and on Gradle, the JDK and Xcode. Plan the order and the target versions withkmp-toolchain-upgrade, then make each catalog edit here. Catalog rules that always hold:- Kotlin Gradle plugin, Compose compiler (
org.jetbrains.kotlin.plugin.compose) and the serialization plugin shareversion.ref = "kotlin". material3,navigation-composeandlifecycle-*underorg.jetbrains.*have their own version lines; take them from the Compose Multiplatform release notes, not from the CMP version.- KSP before 2.3.0 is versioned
<kotlin>-<ksp>; 2.3.0 and later have their own line (KSP releases). - Kotlin compiler plugins outside the Kotlin release (Koin compiler plugin, SKIE) must list the new Kotlin as supported.
- Kotlin Gradle plugin, Compose compiler (
- Whenever
kotlinchanges, check Xcode. Each Kotlin release supports one Xcode line. From the KMP compatibility guide on 3 Dec 2026: Kotlin 2.5.0 → Xcode 27.0; 2.4.0–2.4.21 → 26.4; 2.3.x → 26.0. Compare withxcodebuild -versionand with the CI runner's Xcode. Tell the user about a mismatch; do not change Xcode,xcode-selector runner images yourself. Done when the pairing is reported.
Dependencies compiled with an older Kotlin are usually fine; dependencies compiled with a newer one are not. Upgrade the project's Kotlin first, then libraries that require it.
Workflow C — Share one catalog across repositories
Options, how to set each up, and how to override a version locally are in
references/shared-catalogs-and-composite-builds.md.
In short: a git submodule imported with from(files(...)), or a catalog published with the
version-catalog plugin and imported with from("com.example:catalog:<version>").
Audit drift between catalogs, and hardcoded versions in build scripts, with the bundled script (paths relative to this skill's directory; read-only; output is a table or JSON):
python3 scripts/catalog_drift.py app=../notes-app/gradle/libs.versions.toml \
sdk=../notes-sdk/gradle/libs.versions.toml --only-differs
python3 scripts/catalog_drift.py gradle/libs.versions.toml --scan-gradle . --format json
python3 scripts/catalog_drift.py --help
Exit code 1 with --fail-on-drift makes it usable in CI. Never downgrade to resolve drift without
asking; align on the highest version that every consumer has been built against.
Workflow D — Convention plugins
When three or more modules repeat the same plugins, targets and SDK levels, move that block into a
build-logic included build. Full setup — build-logic/settings.gradle.kts reading the same catalog,
compileOnly plugin artifacts, and a KmpLibraryConventionPlugin that configures the
AGP KMP library target — is in references/convention-plugins.md.
Do not create build-logic in a project that has none without asking; it is a structural change.
Workflow E — Develop a library locally against an app
Gate an includeBuild behind a Gradle property so the default build always uses the published
artifact:
// settings.gradle.kts of the consuming app
if (providers.gradleProperty("local.notes-sdk").orNull == "true") {
includeBuild("../notes-sdk") {
dependencySubstitution {
substitute(module("com.example:notes-sdk")).using(project(":sdk"))
}
}
}
./gradlew :androidApp:assembleDebug -Plocal.notes-sdk=true
With the flag off, local library edits reach no consumer. Rebuild every consumer with its flag on
before publishing a library change. Keep Kotlin and AGP identical across the composite. Never commit
the flag as true. Details and pitfalls are in the shared-catalogs reference.
Quick reference
| Task | How |
|---|---|
| Library accessor | ktor-client-core → libs.ktor.client.core; [bundles] ktor-common → libs.bundles.ktor.common |
| Plugin accessor | libs.plugins.kotlinMultiplatform in plugins { alias(...) } |
| Version in Kotlin code | libs.versions.android.minSdk.get().toInt() |
| Reserved alias words | extensions, class, convention; bundles, versions, plugins cannot start an alias |
| Common-only dependency | commonMain.dependencies { implementation(...) } |
| Platform-only dependency | androidMain / iosMain |
| Test-only | commonTest; JVM-only test libraries (MockK, JUnit 5) go in androidHostTest, never commonTest |
| BOM (Android only) | androidMain.dependencies { implementation(project.dependencies.platform(libs.firebase.bom)) } |
| KSP | add("ksp<Target>", libs.x.compiler) for each target |
| Android-KMP library plugin | { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" } |
| Room 3 | androidx.room3:room3-runtime / room3-compiler, plugin androidx.room3 |
| Koin compiler plugin | { id = "io.insert-koin.compiler.plugin", version.ref = "koin-plugin" } |
| Kotlin ↔ Xcode | 2.5.0 → 27.0; 2.4.x → 26.4 (re-check the compatibility guide) |
| Latest version lookup | klibs.io / KMP Libraries Expert; android studio version-lookup |
| Local library | includeBuild + dependencySubstitution, gated by -Plocal.<lib>=true |
Verify
Report every check as PASS, FAIL or NOT RUN (with the reason). Never report a check that did
not run as passed. Replace :shared with each module you touched.
./gradlew help # catalog and settings parse
./gradlew :shared:compileCommonMainKotlinMetadata
./gradlew :shared:compileAndroidMain # legacy plugin: compileDebugKotlinAndroid
./gradlew :shared:compileKotlinIosSimulatorArm64 # macOS only; proves the iOS variant resolves
./gradlew :shared:allTests # or the project's test tasks
./gradlew :androidApp:assembleDebug # or :composeApp:assembleDebug
./gradlew :shared:dependencyInsight --dependency ktor-client-core --configuration <configuration>
python3 scripts/catalog_drift.py gradle/libs.versions.toml --scan-gradle . --fail-on-drift
List configuration names for dependencyInsight with ./gradlew :shared:dependencies | grep -i classpath.
After a kotlin change also link the iOS framework (linkDebugFrameworkIosSimulatorArm64), build the
Xcode project, and report the Xcode version used (xcodebuild -version) next to the result.
Common mistakes
| Mistake | Why it bites | Fix |
|---|---|---|
Android-only library in commonMain |
iOS compilation fails with "No matching variant" or unresolved artifacts | androidMain plus an interface in common |
Version literal in build.gradle.kts |
Drifts from the catalog; invisible to upgrades | Catalog entry with version.ref |
| Compose compiler or serialization plugin on its own version key | Mismatched Kotlin compiler plugins fail the build after an upgrade | version.ref = "kotlin" |
Koin compiler plugin on version.ref = "kotlin" or expected from koin-bom |
It has its own release line; the version may not exist | Separate koin-plugin key |
| Using the Compose Multiplatform version for material3, navigation or lifecycle | Those artifacts have separate version lines; the version may not exist or may not match | Take each from the CMP release notes |
Bumping kotlin without checking Xcode locally and on CI |
Each Kotlin/Native release supports one Xcode line; the iOS side breaks while Android stays green | Workflow B step 3; plan the set with kmp-toolchain-upgrade |
androidx.room and androidx.room3 entries both in use |
Two Room generations, two compilers and plugins | One generation; migrate with kmp-room-database |
Adding com.android.library to a KMP module on AGP 9 |
The KMP plugin no longer works with it there | com.android.kotlin.multiplatform.library; migrate with the AGP 9 skill |
JVM-only test library in commonTest |
iOS test compilation fails | Fakes in commonTest; JVM tools in androidHostTest |
| Plugin versions requested per module instead of once in the root | "The Kotlin Gradle plugin was loaded multiple times in different subprojects", or "already on the classpath with an unknown version" when build-logic also provides it | apply false in root, versionless alias in modules |
A catalog named libs imported from a file while gradle/libs.versions.toml also exists |
Gradle auto-imports the default file; calling from twice fails |
One source: delete the stray file or rename one catalog |
| KSP configured for some targets only | That target fails to compile, or crashes at runtime where generated code is looked up dynamically | One ksp<Target> line per target |
includeBuild always on |
CI and teammates build unpublished code; releases differ from what was tested | Gate it with a property that defaults to off |
| Upgrading Kotlin, AGP and CMP in one commit | A failure cannot be attributed | One axis per commit |
Accessing libs.plugins.* inside a precompiled script plugin's plugins {} |
Not supported by Gradle | Binary convention plugins with VersionCatalogsExtension |
Related skills
kmp-toolchain-upgrade— Kotlin, Compose Multiplatform, AGP, Gradle, JDK and Xcode compatibility and the order to upgrade them.kmp-feature-module— new modules and their build files.kmp-room-database,kmp-koin-di— Room 3 and Koin setup beyond the catalog entries.kmp-module-health— audits hardcoded versions and build config per module.kmp-build-failure-triagein this repo — diagnosing a red build.- Kotlin/kotlin-agent-skills — AGP 9 migration, Kotlin/Native build performance.
- Kotlin Multiplatform Libraries Expert (JetBrains, klibs.io) — KMP library discovery, target support, latest coordinates.
- Google
android-cli—android studio version-lookupand other Android CLI commands. - chrisbanes/skills
gradle-run— running Gradle with compact output. - Gradle version catalogs, composite builds, KMP dependencies.
Files (kmp-mobile-skills)
-
references
-
catalog-syntax.md 4 KB
Loading… -
convention-plugins.md 7.3 KB
Loading… -
shared-catalogs-and-composite-builds.md 6 KB
Loading…
-
-
scripts
-
tests
-
test_catalog_drift.py 7.9 KB
Loading…
-
-
catalog_drift.py 10 KB
Loading…
-
-
SKILL.md 22.4 KB
--- name: kmp-gradle-version-catalog description: Use when adding, upgrading or auditing dependencies and Gradle plugins in a Kotlin Multiplatform project - libs.versions.toml, [versions] [libraries] [plugins] [bundles], catalog entries for Room 3 (androidx.room3), the Koin compiler plugin or com.android.kotlin.multiplatform.library, "Could not resolve" or "No matching variant" for iosArm64, bumping the kotlin version key, one catalog shared across several repos (git submodule or published catalog), version drift, build-logic convention plugins, or includeBuild with dependencySubstitution for local library development. license: Apache-2.0 compatibility: Gradle 8+ Kotlin Multiplatform project. The drift script needs Python 3.11+ (standard library only, no network). iOS compile checks need macOS with Xcode. Optional lookups use the Android CLI with a running Android Studio, or klibs.io. metadata: category: build platforms: android, ios --- # KMP Gradle version catalog and dependencies Every version lives in exactly one version catalog, every dependency lands in the narrowest source set that needs it, and nothing goes into `commonMain` until you have confirmed it publishes iOS variants. This skill edits the catalog; deciding which Kotlin, Compose Multiplatform, AGP, Gradle, JDK and Xcode versions go together is `kmp-toolchain-upgrade`. ## When to use - Adding a library or Gradle plugin, or a bundle of them. - "Could not resolve", "No matching variant" or a Kotlin metadata/ABI version error after adding one. - Writing catalog entries for Room 3, the Koin compiler plugin or the Android-KMP library plugin. - Changing a version key, including `kotlin` (then also check Xcode, Workflow B). - Several repositories should share one catalog, or their versions have drifted. - Extracting repeated build configuration into convention plugins. - Developing a library locally while an app consumes it. ## When not to use - Planning a Kotlin, Compose Multiplatform, AGP, Gradle, JDK or Xcode upgrade, or asking which of those versions work together: `kmp-toolchain-upgrade`. - Creating the module that will use the dependency: `kmp-feature-module`. - Writing the platform abstraction around an Android-only library: `kmp-expect-actual`. - Room or Koin code and setup beyond the catalog lines: `kmp-room-database`, `kmp-koin-di`. - Migrating a project to AGP 9 as a whole: the AGP 9 migration skill in [Kotlin/kotlin-agent-skills](https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-agp9-migration). - A failing build you have not yet diagnosed: `kmp-build-failure-triage` in this repo. ## Step 0 — Read the project first ```bash ls gradle/libs.versions.toml 2>/dev/null # default catalog location grep -nE 'versionCatalogs|from\(|includeBuild|dependencySubstitution|repositoriesMode' settings.gradle.kts cat .gitmodules 2>/dev/null # catalog shared as a submodule? ls build-logic buildSrc 2>/dev/null # convention plugins grep -nE '^(kotlin|agp|composeMultiplatform|compose-multiplatform|ksp|room3?|koin[A-Za-z-]*)\s*=' gradle/libs.versions.toml grep -nE 'com\.android\.(application|library|kotlin\.multiplatform\.library)|androidx\.room3?|insert-koin' gradle/libs.versions.toml grep -rnE '"[A-Za-z0-9_.-]+:[A-Za-z0-9_.-]+:[0-9]' --include='*.gradle.kts' . | grep -v /build/ | head xcodebuild -version 2>/dev/null | head -1 # macOS only: Xcode paired with Kotlin ``` | Record | Why | |---|---| | Catalog path: `gradle/libs.versions.toml`, a file imported in `settings.gradle.kts`, or a published `group:artifact:version` | Edit the real source of truth, not a copy | | Alias style: `ktor-client-core` (accessor `libs.ktor.client.core`) or camelCase | New entries match existing ones | | Version key style: `kotlinx-coroutines` vs `kotlinxCoroutines` | Same | | Kotlin, AGP, Compose Multiplatform, KSP, Gradle versions, and the local/CI Xcode | Decide compatibility before choosing a library version | | Android plugins in use: `com.android.kotlin.multiplatform.library` or the legacy `com.android.library` / `com.android.application` in KMP modules | New entries follow the project's plugin; do not migrate as a side effect | | Room 2 (`androidx.room`) or Room 3 (`androidx.room3`); Koin with or without its compiler plugin | Keep the existing generation unless the user asks to move | | Convention plugins | Shared config belongs there, not copied into modules | | `includeBuild` + substitution flags | Local-library mode exists; know its property names | | Existing hardcoded versions in build files | Report them; do not add more | ## Workflow A — Add a dependency 1. **Confirm the targets.** For anything going into `commonMain`, confirm iOS variants exist: search [klibs.io](https://klibs.io), read the library's docs, or check Maven Central for per-target artifacts (`<artifact>-iosarm64`, `<artifact>-iossimulatorarm64`): ```bash G=io/ktor A=ktor-client-core for t in iosarm64 iossimulatorarm64; do printf '%-18s %s\n' "$t" "$(curl -s -o /dev/null -w '%{http_code}' \ "https://repo1.maven.org/maven2/$G/$A-$t/maven-metadata.xml")" done # 200 = published; androidx artifacts live on Google Maven instead ``` No iOS variant means the library is Android-only: put it in `androidMain` behind an interface (`kmp-expect-actual`). Done when you know which source set it belongs in. Optional lookups, when the user has them installed — never required: - JetBrains' [Kotlin Multiplatform Libraries Expert](https://github.com/JetBrains/klibs-io/tree/release/skills/kmp-libraries-expert) skill (or the klibs.io MCP server, see [klibs.io/ai](https://klibs.io/ai)) for KMP target support and latest stable coordinates. - The Android CLI's `android studio version-lookup` for the latest versions of Maven artifacts, Android versions and SDK tools. It connects to a running Android Studio; check its arguments with `android studio version-lookup --help`. Gate on `command -v android`. See Google's [`android-cli` skill](https://github.com/android/skills/tree/main/devtools/android-cli). 2. **Confirm the Kotlin version.** A library compiled by a newer Kotlin than the project's can fail with a metadata or ABI version error, especially on Kotlin/Native. Read its release notes for the Kotlin it was built with. Kotlin compiler plugins (Compose compiler, serialization, the Koin compiler plugin, SKIE) support a bounded Kotlin range — check theirs too. Done when the chosen version supports the project's Kotlin. 3. **Add catalog entries.** One `[versions]` key per version family, `version.ref` everywhere, aliases in the file's existing style. Pin an exact stable version taken from the library's releases page; never `+`, `latest.release` or a range unless the project already uses rich versions. Entry forms, naming rules, BOMs and rich versions are in [references/catalog-syntax.md](references/catalog-syntax.md). ```toml [versions] ktor = "<exact version>" [libraries] ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } [bundles] ktor-common = ["ktor-client-core", "ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] ``` 4. **Wire it into the narrowest source set.** ```kotlin kotlin { sourceSets { commonMain.dependencies { implementation(libs.bundles.ktor.common) } androidMain.dependencies { implementation(libs.ktor.client.okhttp) } // engine per platform iosMain.dependencies { implementation(libs.ktor.client.darwin) } commonTest.dependencies { implementation(libs.ktor.client.mock) } } } ``` Use `api` only when the dependency's types appear in this module's public API (and therefore in an iOS `export`). Done when the module compiles for every target (Verify). 5. **Plugins.** Add a `[plugins]` entry, declare it once in the root `build.gradle.kts` with `alias(libs.plugins.x) apply false`, then `alias(libs.plugins.x)` in the module. Catalog plugin aliases cannot be used in `settings.gradle.kts`. 6. **Annotation processors (KSP).** KMP needs one configuration per target, for example `add("kspAndroid", libs.androidx.room3.compiler)`, `add("kspIosArm64", …)`, `add("kspIosSimulatorArm64", …)`, and `kspIosX64` if that target exists. A missing target either fails that target's compilation or, for processors whose output is looked up at runtime, fails only when the app runs on that platform. Done when every declared target has a line. ## Catalog entries for Room 3, Koin and the Android-KMP plugin Add only the entries the project needs, in its own alias style. Versions: the latest stable from each project's release notes (or the lookups above). ```toml [versions] agp = "<exact version>" room3 = "<exact version>" # Room 3 line; Room 2 uses the separate androidx.room group sqlite = "<exact version>" koin = "<exact version>" koin-plugin = "<exact version>" # own release line; not managed by koin-bom [libraries] androidx-room3-runtime = { module = "androidx.room3:room3-runtime", version.ref = "room3" } androidx-room3-compiler = { module = "androidx.room3:room3-compiler", version.ref = "room3" } androidx-sqlite-bundled = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" } koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin" } koin-core = { module = "io.insert-koin:koin-core" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" } androidx-room3 = { id = "androidx.room3", version.ref = "room3" } koin-compiler = { id = "io.insert-koin.compiler.plugin", version.ref = "koin-plugin" } ``` | Entry | Rule | |---|---| | `com.android.kotlin.multiplatform.library` | Ships with AGP: `version.ref = "agp"`. Shared KMP modules apply it; `com.android.application` goes only in the pure-Android app module (for example `:androidApp`). Under AGP 9 the KMP plugin no longer works with `com.android.application` or `com.android.library` in the same module, and Kotlin 2.5 warns on every AGP version. Moving a project over is the [AGP 9 migration skill](https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-agp9-migration), not a catalog edit | | Room 3 (`androidx.room3`) | KSP only, one `ksp<Target>` line per target; needs a `SQLiteDriver` (`sqlite-bundled`); publishes no `iosx64` artifacts. Never keep `androidx.room` and `androidx.room3` side by side; moving from Room 2 is `kmp-room-database` | | Koin compiler plugin | Separate `koin-plugin` key, never `version.ref = "kotlin"` and not covered by the BOM. It is a Kotlin compiler plugin with its own supported Kotlin range: read its [release notes](https://github.com/InsertKoinIO/koin-compiler-plugin/releases) before bumping either. Setup: `kmp-koin-di` | | build-logic needs a plugin as a library | `com.android.tools.build:gradle` (`agp`), `androidx.room3:room3-gradle-plugin` (`room3`), `io.insert-koin:koin-compiler-gradle-plugin` (`koin-plugin`), as `compileOnly` — see [references/convention-plugins.md](references/convention-plugins.md) | ## Workflow B — Bump a version key Change one key per commit and run the full Verify after each. 1. **A library or its BOM:** bump the one `[versions]` key; read the release notes for the Kotlin it needs (Workflow A step 2). Done when Verify passes. 2. **`kotlin`, `agp`, `composeMultiplatform`, `ksp` or the Gradle wrapper:** these depend on each other and on Gradle, the JDK and Xcode. Plan the order and the target versions with `kmp-toolchain-upgrade`, then make each catalog edit here. Catalog rules that always hold: - Kotlin Gradle plugin, Compose compiler (`org.jetbrains.kotlin.plugin.compose`) and the serialization plugin share `version.ref = "kotlin"`. - `material3`, `navigation-compose` and `lifecycle-*` under `org.jetbrains.*` have their own version lines; take them from the Compose Multiplatform release notes, not from the CMP version. - KSP before 2.3.0 is versioned `<kotlin>-<ksp>`; 2.3.0 and later have their own line ([KSP releases](https://github.com/google/ksp/releases)). - Kotlin compiler plugins outside the Kotlin release (Koin compiler plugin, SKIE) must list the new Kotlin as supported. 3. **Whenever `kotlin` changes, check Xcode.** Each Kotlin release supports one Xcode line. From the [KMP compatibility guide](https://kotlinlang.org/docs/multiplatform/multiplatform-compatibility-guide.html) on 3 Dec 2026: Kotlin 2.5.0 → Xcode 27.0; 2.4.0–2.4.21 → 26.4; 2.3.x → 26.0. Compare with `xcodebuild -version` and with the CI runner's Xcode. Tell the user about a mismatch; do not change Xcode, `xcode-select` or runner images yourself. Done when the pairing is reported. Dependencies compiled with an older Kotlin are usually fine; dependencies compiled with a newer one are not. Upgrade the project's Kotlin first, then libraries that require it. ## Workflow C — Share one catalog across repositories Options, how to set each up, and how to override a version locally are in [references/shared-catalogs-and-composite-builds.md](references/shared-catalogs-and-composite-builds.md). In short: a git submodule imported with `from(files(...))`, or a catalog published with the `version-catalog` plugin and imported with `from("com.example:catalog:<version>")`. Audit drift between catalogs, and hardcoded versions in build scripts, with the bundled script (paths relative to this skill's directory; read-only; output is a table or JSON): ```bash python3 scripts/catalog_drift.py app=../notes-app/gradle/libs.versions.toml \ sdk=../notes-sdk/gradle/libs.versions.toml --only-differs python3 scripts/catalog_drift.py gradle/libs.versions.toml --scan-gradle . --format json python3 scripts/catalog_drift.py --help ``` Exit code 1 with `--fail-on-drift` makes it usable in CI. Never downgrade to resolve drift without asking; align on the highest version that every consumer has been built against. ## Workflow D — Convention plugins When three or more modules repeat the same plugins, targets and SDK levels, move that block into a `build-logic` included build. Full setup — `build-logic/settings.gradle.kts` reading the same catalog, `compileOnly` plugin artifacts, and a `KmpLibraryConventionPlugin` that configures the AGP KMP library target — is in [references/convention-plugins.md](references/convention-plugins.md). Do not create `build-logic` in a project that has none without asking; it is a structural change. ## Workflow E — Develop a library locally against an app Gate an `includeBuild` behind a Gradle property so the default build always uses the published artifact: ```kotlin // settings.gradle.kts of the consuming app if (providers.gradleProperty("local.notes-sdk").orNull == "true") { includeBuild("../notes-sdk") { dependencySubstitution { substitute(module("com.example:notes-sdk")).using(project(":sdk")) } } } ``` ```bash ./gradlew :androidApp:assembleDebug -Plocal.notes-sdk=true ``` With the flag off, local library edits reach no consumer. Rebuild every consumer with its flag on before publishing a library change. Keep Kotlin and AGP identical across the composite. Never commit the flag as `true`. Details and pitfalls are in the shared-catalogs reference. ## Quick reference | Task | How | |---|---| | Library accessor | `ktor-client-core` → `libs.ktor.client.core`; `[bundles] ktor-common` → `libs.bundles.ktor.common` | | Plugin accessor | `libs.plugins.kotlinMultiplatform` in `plugins { alias(...) }` | | Version in Kotlin code | `libs.versions.android.minSdk.get().toInt()` | | Reserved alias words | `extensions`, `class`, `convention`; `bundles`, `versions`, `plugins` cannot start an alias | | Common-only dependency | `commonMain.dependencies { implementation(...) }` | | Platform-only dependency | `androidMain` / `iosMain` | | Test-only | `commonTest`; JVM-only test libraries (MockK, JUnit 5) go in `androidHostTest`, never `commonTest` | | BOM (Android only) | `androidMain.dependencies { implementation(project.dependencies.platform(libs.firebase.bom)) }` | | KSP | `add("ksp<Target>", libs.x.compiler)` for each target | | Android-KMP library plugin | `{ id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }` | | Room 3 | `androidx.room3:room3-runtime` / `room3-compiler`, plugin `androidx.room3` | | Koin compiler plugin | `{ id = "io.insert-koin.compiler.plugin", version.ref = "koin-plugin" }` | | Kotlin ↔ Xcode | 2.5.0 → 27.0; 2.4.x → 26.4 (re-check the compatibility guide) | | Latest version lookup | klibs.io / KMP Libraries Expert; `android studio version-lookup` | | Local library | `includeBuild` + `dependencySubstitution`, gated by `-Plocal.<lib>=true` | ## Verify Report every check as `PASS`, `FAIL` or `NOT RUN` (with the reason). Never report a check that did not run as passed. Replace `:shared` with each module you touched. ```bash ./gradlew help # catalog and settings parse ./gradlew :shared:compileCommonMainKotlinMetadata ./gradlew :shared:compileAndroidMain # legacy plugin: compileDebugKotlinAndroid ./gradlew :shared:compileKotlinIosSimulatorArm64 # macOS only; proves the iOS variant resolves ./gradlew :shared:allTests # or the project's test tasks ./gradlew :androidApp:assembleDebug # or :composeApp:assembleDebug ./gradlew :shared:dependencyInsight --dependency ktor-client-core --configuration <configuration> python3 scripts/catalog_drift.py gradle/libs.versions.toml --scan-gradle . --fail-on-drift ``` List configuration names for `dependencyInsight` with `./gradlew :shared:dependencies | grep -i classpath`. After a `kotlin` change also link the iOS framework (`linkDebugFrameworkIosSimulatorArm64`), build the Xcode project, and report the Xcode version used (`xcodebuild -version`) next to the result. ## Common mistakes | Mistake | Why it bites | Fix | |---|---|---| | Android-only library in `commonMain` | iOS compilation fails with "No matching variant" or unresolved artifacts | `androidMain` plus an interface in common | | Version literal in `build.gradle.kts` | Drifts from the catalog; invisible to upgrades | Catalog entry with `version.ref` | | Compose compiler or serialization plugin on its own version key | Mismatched Kotlin compiler plugins fail the build after an upgrade | `version.ref = "kotlin"` | | Koin compiler plugin on `version.ref = "kotlin"` or expected from `koin-bom` | It has its own release line; the version may not exist | Separate `koin-plugin` key | | Using the Compose Multiplatform version for material3, navigation or lifecycle | Those artifacts have separate version lines; the version may not exist or may not match | Take each from the CMP release notes | | Bumping `kotlin` without checking Xcode locally and on CI | Each Kotlin/Native release supports one Xcode line; the iOS side breaks while Android stays green | Workflow B step 3; plan the set with `kmp-toolchain-upgrade` | | `androidx.room` and `androidx.room3` entries both in use | Two Room generations, two compilers and plugins | One generation; migrate with `kmp-room-database` | | Adding `com.android.library` to a KMP module on AGP 9 | The KMP plugin no longer works with it there | `com.android.kotlin.multiplatform.library`; migrate with the AGP 9 skill | | JVM-only test library in `commonTest` | iOS test compilation fails | Fakes in `commonTest`; JVM tools in `androidHostTest` | | Plugin versions requested per module instead of once in the root | "The Kotlin Gradle plugin was loaded multiple times in different subprojects", or "already on the classpath with an unknown version" when build-logic also provides it | `apply false` in root, versionless `alias` in modules | | A catalog named `libs` imported from a file while `gradle/libs.versions.toml` also exists | Gradle auto-imports the default file; calling `from` twice fails | One source: delete the stray file or rename one catalog | | KSP configured for some targets only | That target fails to compile, or crashes at runtime where generated code is looked up dynamically | One `ksp<Target>` line per target | | `includeBuild` always on | CI and teammates build unpublished code; releases differ from what was tested | Gate it with a property that defaults to off | | Upgrading Kotlin, AGP and CMP in one commit | A failure cannot be attributed | One axis per commit | | Accessing `libs.plugins.*` inside a precompiled script plugin's `plugins {}` | Not supported by Gradle | Binary convention plugins with `VersionCatalogsExtension` | ## Related skills - `kmp-toolchain-upgrade` — Kotlin, Compose Multiplatform, AGP, Gradle, JDK and Xcode compatibility and the order to upgrade them. - `kmp-feature-module` — new modules and their build files. - `kmp-room-database`, `kmp-koin-di` — Room 3 and Koin setup beyond the catalog entries. - `kmp-module-health` — audits hardcoded versions and build config per module. - `kmp-build-failure-triage` in this repo — diagnosing a red build. - [Kotlin/kotlin-agent-skills](https://github.com/Kotlin/kotlin-agent-skills) — AGP 9 migration, Kotlin/Native build performance. - [Kotlin Multiplatform Libraries Expert](https://github.com/JetBrains/klibs-io/tree/release/skills/kmp-libraries-expert) (JetBrains, klibs.io) — KMP library discovery, target support, latest coordinates. - [Google `android-cli`](https://github.com/android/skills/tree/main/devtools/android-cli) — `android studio version-lookup` and other Android CLI commands. - [chrisbanes/skills `gradle-run`](https://github.com/chrisbanes/skills/tree/main/skills/gradle-run) — running Gradle with compact output. - [Gradle version catalogs](https://docs.gradle.org/current/userguide/version_catalogs.html), [composite builds](https://docs.gradle.org/current/userguide/composite_builds.html), [KMP dependencies](https://kotlinlang.org/docs/multiplatform/multiplatform-add-dependencies.html).
Reviews (0)
No reviews yet.
Comments
Sign in to join the conversation.
No comments yet. Start the conversation.