/kotlin-tooling-agp9-migration
Migrates Kotlin Multiplatform (KMP) projects to Android Gradle Plugin 9.0+. Handles plugin replacement (com.android.kotlin.multiplatform.library), module splitting, DSL migration, and the new default project structure. Use when upgrading AGP, when build fails due to KMP+AGP
$ npx -y skills add kotlin/kotlin-agent-skills --skill kotlin-tooling-agp9-migration --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/kotlin-tooling-agp9-migration
Context preview
The summary Claude sees to decide when to auto-load this skill.
Migrates Kotlin Multiplatform (KMP) projects to Android Gradle Plugin 9.0+. Handles plugin replacement (com.android.kotlin.multiplatform.library), module splitting, DSL migration, and the new default project structure. Use when upgrading AGP, when build fails due to KMP+AGP
SKILL.md
kotlin-tooling-agp9-migration.SKILL.mdname: kotlin-tooling-agp9-migration
description: >
Migrates Kotlin Multiplatform (KMP) projects to Android Gradle Plugin 9.0+.
Handles plugin replacement (com.android.kotlin.multiplatform.library), module
splitting, DSL migration, and the new default project structure. Use when
upgrading AGP, when build fails due to KMP+AGP incompatibility, or when the
user mentions AGP 9.0, android multiplatform plugin, KMP migration, or
com.android.kotlin.multiplatform.library.
license: Apache-2.0
metadata:
author: JetBrains
version: "1.0.0"
KMP AGP 9.0 Migration
Android Gradle Plugin 9.0 makes the Android application and library plugins incompatible with the Kotlin Multiplatform plugin in the same module. This skill guides you through the migration.
Step 0: Analyze the Project
Before making any changes, understand the project structure: 1. Read `settings.gradle.kts` (or `.gradle`) to find all modules 2. For each module, read its `build.gradle.kts` to identify which plugins are applied 3. Check if the project uses a Gradle version catalog (`gradle/libs.versions.toml`). If it exists, read it for current AGP/Gradle/Kotlin versions. If not, find versions directly in `build.gradle.kts` files (typically in the root `buildscript {}` or `plugins {}` block). **Adapt all examples in this guide accordingly** — version catalog examples use `alias(libs.plugins.xxx)` while direct usage uses `id("plugin.id") version "x.y.z"` 4. Read `gradle/wrapper/gradle-wrapper.properties` for the Gradle version 5. Check `gradle.properties` for any existing workarounds (`android.enableLegacyVariantApi`) 6. Check for `org.jetbrains.kotlin.android` plugin usage — AGP 9.0 has built-in Kotlin and this plugin must be removed 7. Check for `org.jetbrains.kotlin.kapt` plugin usage — incompatible with built-in Kotlin, must migrate to KSP or `com.android.legacy-kapt` 8. Check for third-party plugins that may be incompatible with AGP 9.0 (see "Plugin Compatibility" section below)
If Bash is available, run `scripts/analyze-project.sh` from this skill's directory to get a structured summary.
Classify Each Module
For each module, determine its type:
| Current plugins | Migration path | |--------------------------------------------------------------------------|---------------------------------------------| | `kotlin.multiplatform` + `com.android.library` | **Path A** — Library plugin swap | | `kotlin.multiplatform` + `com.android.application` | **Path B** — Mandatory Android split | | `kotlin.multiplatform` with multiple platform entry points in one module | **Path C** — Full restructure (recommended) | | `com.android.application` or `com.android.library` (no KMP) | See "Pure Android Tips" below |
Determine Scope
- **Path B is mandatory** for any module combining KMP + Android application plugin
- **Path C is recommended** when the project has a monolithic `composeApp` (or similar) module
containing entry points for multiple platforms (Android, Desktop, Web). This aligns with the new JetBrains default project structure where each platform gets its own app module.
- **Ask the user** whether they want Path B only (minimum required) or Path C (recommended full restructure)
Path A: Library Module Migration
Use this when a module applies `kotlin.multiplatform` + `com.android.library`.
See [references/MIGRATION-LIBRARY.md](references/MIGRATION-LIBRARY.md) for full before/after code.
Summary:
1. **Replace plugin**: `com.android.library` → `com.android.kotlin.multiplatform.library` 2. **Remove `org.jetbrains.kotlin.android`** plugin if present (AGP 9.0 has built-in Kotlin support) 3. **Migrate DSL**: Move config from top-level `android {}` block into `kotlin { android {} }`:
kotlin {
android {
namespace = "com.example.lib"
compileSdk = 35
minSdk = 24
}
}4. **Rename source directories** (only if the module uses classic Android layout instead of KMP layout):
- `src/main` → `src/androidMain`
- `src/test` → `src/androidHostTest`
- `src/androidTest` → `src/androidDeviceTest`
- If the module already uses `src/androidMain/`, no directory renames are needed
5. **Move dependencies** from top-level `dependencies {}` into `sourceSets`:
kotlin {
sourceSets {
androidMain.dependencies {
implementation("androidx.appcompat:appcompat:1.7.0")
}
}
}6. **Enable resources** explicitly if the module uses Android or Compose Multiplatform resources:
kotlin {
android {
androidResources { enable = true }
}
}7. **Enable Java** compilation if module has `.java` source files:
kotlin {
android {
withJava()
}
}8. **Enable tests** explicitly if the module has unit or instrumented tests:
kotlin {
android {
withHostTest { isIncludeAndroidResources = true }
withDeviceTest {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
}9. **Update Compose tooling dependency**:
// Old:
debugImplementation(libs.androidx.compose.ui.tooling)
// New:
androidRuntimeClasspath(libs.androidx.compose.ui.tooling)
10. **Publish consumer ProGuard rules** explicitly if applicable:
kotlin {
android {
consumerProguardFiles.add(file("consumer-rules.pro"))
}
}11. **Resolve Sub-dependency Variants (Product Flavors / Build Types)**: Because the new KMP Android library plugin enforces a single-variant architecture, it does not natively understand how to resolve dependencies that publish multiple variants (like
Read more
name: kotlin-tooling-agp9-migration description: > Migrates Kotlin Multiplatform (KMP) projects to Android Gradle Plugin 9.0+. Handles plugin replacement (com.android.kotlin.multiplatform.library), module splitting, DSL migration, and the new default project structure. Use when upgrading AGP, when build fails due to KMP+AGP incompatibility, or when the user mentions AGP 9.0, android multiplatform plugin, KMP migration, or com.android.kotlin.multiplatform.library. license: Apache-2.0 metadata: author: JetBrains version: "1.0.0"
KMP AGP 9.0 Migration
Android Gradle Plugin 9.0 makes the Android application and library plugins incompatible with the Kotlin Multiplatform plugin in the same module. This skill guides you through the migration.
Step 0: Analyze the Project
Before making any changes, understand the project structure: 1. Read `settings.gradle.kts` (or `.gradle`) to find all modules 2. For each module, read its `build.gradle.kts` to identify which plugins are applied 3. Check if the project uses a Gradle version catalog (`gradle/libs.versions.toml`). If it exists, read it for current AGP/Gradle/Kotlin versions. If not, find versions directly in `build.gradle.kts` files (typically in the root `buildscript {}` or `plugins {}` block). **Adapt all examples in this guide accordingly** — version catalog examples use `alias(libs.plugins.xxx)` while direct usage uses `id("plugin.id") version "x.y.z"` 4. Read `gradle/wrapper/gradle-wrapper.properties` for the Gradle version 5. Check `gradle.properties` for any existing workarounds (`android.enableLegacyVariantApi`) 6. Check for `org.jetbrains.kotlin.android` plugin usage — AGP 9.0 has built-in Kotlin and this plugin must be removed 7. Check for `org.jetbrains.kotlin.kapt` plugin usage — incompatible with built-in Kotlin, must migrate to KSP or `com.android.legacy-kapt` 8. Check for third-party plugins that may be incompatible with AGP 9.0 (see "Plugin Compatibility" section below)
If Bash is available, run `scripts/analyze-project.sh` from this skill's directory to get a structured summary.
Classify Each Module
For each module, determine its type:
| Current plugins | Migration path | |--------------------------------------------------------------------------|---------------------------------------------| | `kotlin.multiplatform` + `com.android.library` | **Path A** — Library plugin swap | | `kotlin.multiplatform` + `com.android.application` | **Path B** — Mandatory Android split | | `kotlin.multiplatform` with multiple platform entry points in one module | **Path C** — Full restructure (recommended) | | `com.android.application` or `com.android.library` (no KMP) | See "Pure Android Tips" below |
Determine Scope
- **Path B is mandatory** for any module combining KMP + Android application plugin
- **Path C is recommended** when the project has a monolithic `composeApp` (or similar) module
containing entry points for multiple platforms (Android, Desktop, Web). This aligns with the new JetBrains default project structure where each platform gets its own app module.
- **Ask the user** whether they want Path B only (minimum required) or Path C (recommended full restructure)
Path A: Library Module Migration
Use this when a module applies `kotlin.multiplatform` + `com.android.library`.
See [references/MIGRATION-LIBRARY.md](references/MIGRATION-LIBRARY.md) for full before/after code.
Summary:
1. **Replace plugin**: `com.android.library` → `com.android.kotlin.multiplatform.library` 2. **Remove `org.jetbrains.kotlin.android`** plugin if present (AGP 9.0 has built-in Kotlin support) 3. **Migrate DSL**: Move config from top-level `android {}` block into `kotlin { android {} }`:
kotlin {
android {
namespace = "com.example.lib"
compileSdk = 35
minSdk = 24
}
}4. **Rename source directories** (only if the module uses classic Android layout instead of KMP layout):
- `src/main` → `src/androidMain`
- `src/test` → `src/androidHostTest`
- `src/androidTest` → `src/androidDeviceTest`
- If the module already uses `src/androidMain/`, no directory renames are needed
5. **Move dependencies** from top-level `dependencies {}` into `sourceSets`:
kotlin {
sourceSets {
androidMain.dependencies {
implementation("androidx.appcompat:appcompat:1.7.0")
}
}
}6. **Enable resources** explicitly if the module uses Android or Compose Multiplatform resources:
kotlin {
android {
androidResources { enable = true }
}
}7. **Enable Java** compilation if module has `.java` source files:
kotlin {
android {
withJava()
}
}8. **Enable tests** explicitly if the module has unit or instrumented tests:
kotlin {
android {
withHostTest { isIncludeAndroidResources = true }
withDeviceTest {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
}9. **Update Compose tooling dependency**:
// Old: debugImplementation(libs.androidx.compose.ui.tooling) // New: androidRuntimeClasspath(libs.androidx.compose.ui.tooling)
10. **Publish consumer ProGuard rules** explicitly if applicable:
kotlin {
android {
consumerProguardFiles.add(file("consumer-rules.pro"))
}
}11. **Resolve Sub-dependency Variants (Product Flavors / Build Types)**: Because the new KMP Android library plugin enforces a single-variant architecture, it does not natively understand how to resolve dependencies that publish multiple variants (like
A collection of AI agent skills useful for projects using the Kotlin language. Skills are following the Agent Skills standard, see agentskills.io for more information.
Other skills on kotlin-agent-skills.
- /kotlin-backend-jpa-entity-mapping
Model Kotlin persistence code correctly for Spring Data JPA and Hibernate. Covers entity design, identity and equality, uniqueness constraints, relationships, fetch plans, and common ORM (Object-Relational Mapping) traps specific to Kotlin. Use when creating or reviewing JPA
Open skill - /kotlin-tooling-cocoapods-spm-migration
Migrate KMP projects from CocoaPods (kotlin("native.cocoapods")) to Swift Package Manager (swiftPMDependencies DSL) — replaces pod() with swiftPackage(), transforms cocoapods.* imports to swiftPMImport.*, and reconfigures the Xcode project.
Open skill - /kotlin-tooling-immutable-collections-0-5-x-migration
Migrate Kotlin (and Java) code from kotlinx.collections.immutable 0.3.x / 0.4.x to the latest 0.5.x. The 0.5.x line renames every copy-returning method on PersistentList / PersistentMap / PersistentSet / PersistentCollection to a participial form per KEEP-0459 (add→adding,
Open skill - /kotlin-tooling-java-to-kotlin
Use when converting Java source files to idiomatic Kotlin, when user mentions "java to kotlin", "j2k", "convert java", "migrate java to kotlin", or when working with .java files that need to become .kt files. Handles framework-aware conversion for Spring, Lombok, Hibernate,
Open skill - /kotlin-tooling-native-build-performance
Diagnoses and fixes slow Kotlin/Native compilation and linking in Kotlin Multiplatform projects that target iOS. Use when the user reports slow iOS or shared-framework builds, long linkDebug*/linkRelease* or XCFramework tasks, cold CI builds that re-download the Kotlin/Native
Open skill

