
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 incompatibility, or when the user mentions AGP 9.0, android multiplatform plugin, KMP migration, or com.android.kotlin.multiplatform.library.
- Installs
- 2.2K
- Last 24h
- +14
- Trending rank
- #7248
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/kotlin/kotlin-agent-skills --skill kotlin-tooling-agp9-migration- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads kotlin-tooling-agp9-migration automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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:
- Read
settings.gradle.kts(or.gradle) to find all modules - For each module, read its
build.gradle.ktsto identify which plugins are applied - 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 inbuild.gradle.ktsfiles (typically in the rootbuildscript {}orplugins {}block). Adapt all examples in this guide accordingly — version catalog examples usealias(libs.plugins.xxx)while direct usage usesid("plugin.id") version "x.y.z" - Read
gradle/wrapper/gradle-wrapper.propertiesfor the Gradle version - Check
gradle.propertiesfor any existing workarounds (android.enableLegacyVariantApi) - Check for
org.jetbrains.kotlin.androidplugin usage — AGP 9.0 has built-in Kotlin and this plugin must be removed - Check for
org.jetbrains.kotlin.kaptplugin usage — incompatible with built-in Kotlin, must migrate to KSP orcom.android.legacy-kapt - 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 for full before/after code.
Summary:
- Replace plugin:
com.android.library→com.android.kotlin.multiplatform.library - Remove
org.jetbrains.kotlin.androidplugin if present (AGP 9.0 has built-in Kotlin support) - Migrate DSL: Move config from top-level
android {}block intokotlin { android {} }:kotlin { android { namespace = "com.example.lib" compileSdk = 35 minSdk = 24 } } - Rename source directories (only if the module uses classic Android layout instead of KMP layout):
src/main→src/androidMainsrc/test→src/androidHostTestsrc/androidTest→src/androidDeviceTest- If the module already uses
src/androidMain/, no directory renames are needed
- Move dependencies from top-level
dependencies {}intosourceSets:kotlin { sourceSets { androidMain.dependencies { implementation("androidx.appcompat:appcompat:1.7.0") } } } - Enable resources explicitly if the module uses Android or Compose Multiplatform resources:
kotlin { android { androidResources { enable = true } } } - Enable Java compilation if module has
.javasource files:kotlin { android { withJava() } } - Enable tests explicitly if the module has unit or instrumented tests:
kotlin { android { withHostTest { isIncludeAndroidResources = true } withDeviceTest { instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } } } - Update Compose tooling dependency:
// Old: debugImplementation(libs.androidx.compose.ui.tooling) // New: androidRuntimeClasspath(libs.androidx.compose.ui.tooling) - Publish consumer ProGuard rules explicitly if applicable:
kotlin { android { consumerProguardFiles.add(file("consumer-rules.pro")) } } - 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
debug/releasebuild types, or product flavors likefree/paid). Configure fallback behaviors usinglocalDependencySelection:kotlin { android { localDependencySelection { // Determine which build type to consume from Android library dependencies, in order of preference selectBuildTypeFrom.set(listOf("debug", "release")) // If the dependency has a 'tier' dimension, select the 'free' flavor productFlavorDimension("tier") { selectFrom.set(listOf("free")) } } } }
Path B: Android App + Shared Module Split
Use this when a module applies kotlin.multiplatform + com.android.application. This is mandatory for AGP 9.0 compatibility.
See references/MIGRATION-APP-SPLIT.md for full guide.
Summary:
- Create
androidAppmodule with its ownbuild.gradle.kts:plugins { alias(libs.plugins.androidApplication) // Do NOT apply kotlin-android — AGP 9.0 includes Kotlin support alias(libs.plugins.composeMultiplatform) // if using Compose alias(libs.plugins.composeCompiler) // if using Compose } android { namespace = "com.example.app" compileSdk = 35 defaultConfig { applicationId = "com.example.app" minSdk = 24 targetSdk = 35 versionCode = 1 versionName = "1.0" } buildFeatures { compose = true } } dependencies { implementation(projects.shared) // or whatever the shared module is named implementation(libs.androidx.activity.compose) } - Move Android entry point code from
src/androidMain/toandroidApp/src/main/:MainActivity.kt(and any other Activities/Fragments)AndroidManifest.xml(app-level manifest with<application>and launcher<activity>) — verifyandroid:nameon<activity>uses the fully qualified class name in its new location- Android Application class if present
- App-level resources (launcher icons, theme, etc.)
- Add to
settings.gradle.kts:include(":androidApp") - Add to root
build.gradle.kts: plugin declarations withapply false - Convert original module from application to library using Path A steps
- Ensure different namespaces: app module and library module must have distinct namespaces
- Remove from shared module:
applicationId,targetSdk,versionCode,versionName - Update IDE run configurations: change the module from the old module to
androidApp
Path C: Full Restructure (Recommended)
Use this when the project has a monolithic module (typically composeApp) containing entry
points for multiple platforms. This is optional but aligns with the new JetBrains default.
See references/MIGRATION-FULL-RESTRUCTURE.md for full guide.
Target Structure
project/
├── shared/ ← KMP library (was composeApp), pure shared code
├── androidApp/ ← Android entry point only
├── desktopApp/ ← Desktop entry point only (if desktop target exists)
├── webApp/ ← Wasm/JS entry point only (if web target exists)
├── iosApp/ ← iOS Xcode project (usually already separate)
└── ...
Steps
- Apply Path B first — extract
androidApp(mandatory for AGP 9.0) - Extract
desktopApp(if desktop target exists):- Create module with
org.jetbrains.composeandapplication {}plugin - Move
main()function fromdesktopMaintodesktopApp/src/main/kotlin/ - Move
compose.desktop { application { ... } }config todesktopApp/build.gradle.kts - Add dependency on
sharedmodule
- Create module with
- Extract
webApp(if wasmJs/js target exists):- Create module with appropriate Kotlin/JS or Kotlin/Wasm configuration
- Move web entry point from
wasmJsMain/jsMaintowebApp/src/wasmJsMain/kotlin/ - Move browser/distribution config to
webApp/build.gradle.kts - Add dependency on
sharedmodule
- iOS — typically already in a separate
iosAppdirectory. Verify:- Framework export config (
binaries.framework) stays insharedmodule - Xcode project references the correct framework path
- Framework export config (
- Rename module from
composeApptoshared:- Rename directory
- Update
settings.gradle.ktsinclude - Update all dependency references across modules
- Clean up shared module: remove all platform entry point code and app-specific config that was moved to the platform app modules
Variant: Native UI
If some platforms use native UI (e.g., SwiftUI for iOS), split shared into:
sharedLogic— business logic consumed by ALL platformssharedUI— Compose Multiplatform UI consumed only by platforms using shared UI
Variant: Server
If the project includes a server target:
- Add
servermodule at the root - Move all client modules under an
app/directory - Add
coremodule for code shared between server and client (models, validation)
Version Updates
These are required regardless of migration path:
-
Gradle wrapper — update to 9.1.0+:
# gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip -
AGP version — update to 9.0.0+ and add the KMP library plugin.
With version catalog (
gradle/libs.versions.toml):[versions] agp = "9.0.1" [plugins] android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }Without version catalog — update
com.android.*plugin versions and add in rootbuild.gradle.kts:plugins { id("com.android.application") version "9.0.1" apply false id("com.android.kotlin.multiplatform.library") version "9.0.1" apply false } -
JDK — ensure JDK 17+ is used (required by AGP 9.0)
-
SDK Build Tools — update to 36.0.0:
Install via SDK Manager or configure in android { buildToolsVersion = "36.0.0" } -
Review gradle.properties — remove error-causing properties and review changed defaults (see "Gradle Properties Default Changes" section)
Built-in Kotlin Migration
AGP 9.0 enables built-in Kotlin support by default for all com.android.application and com.android.library
modules. The org.jetbrains.kotlin.android plugin is no longer needed and will conflict if applied.
Important: Built-in Kotlin does NOT replace KMP support. KMP library modules still need
org.jetbrains.kotlin.multiplatform + com.android.kotlin.multiplatform.library.
Step 1: Remove kotlin-android Plugin
Remove from all module-level and root-level build files:
// Remove from module build.gradle.kts
plugins {
// REMOVE: alias(libs.plugins.kotlin.android)
// REMOVE: id("org.jetbrains.kotlin.android")
}
// Remove from root build.gradle.kts
plugins {
// REMOVE: alias(libs.plugins.kotlin.android) apply false
}
Remove from version catalog (gradle/libs.versions.toml):
[plugins]
# REMOVE: kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Step 2: Migrate kapt to KSP or legacy-kapt
The org.jetbrains.kotlin.kapt plugin is incompatible with built-in Kotlin.
Preferred: Migrate to KSP — see the KSP migration guide for each annotation processor.
Fallback: Use com.android.legacy-kapt (same version as AGP):
# gradle/libs.versions.toml
[plugins]
legacy-kapt = { id = "com.android.legacy-kapt", version.ref = "agp" }
// Module build.gradle.kts — replace kotlin-kapt with legacy-kapt
plugins {
// REMOVE: alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.legacy.kapt)
}
Step 3: Migrate kotlinOptions to compilerOptions
For pure Android modules (non-KMP), migrate android.kotlinOptions {} to the top-level
kotlin.compilerOptions {}:
// Old
android {
kotlinOptions {
jvmTarget = "11"
languageVersion = "2.0"
freeCompilerArgs += listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
// New
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
optIn.add("kotlin.RequiresOptIn")
}
}
Note: With built-in Kotlin, jvmTarget defaults to android.compileOptions.targetCompatibility, so it may be optional if you already set compileOptions.
Step 4: Migrate kotlin.sourceSets to android.sourceSets
With built-in Kotlin, only android.sourceSets {} with the kotlin set is supported:
// NOT SUPPORTED with built-in Kotlin:
kotlin.sourceSets.named("main") {
kotlin.srcDir("additionalSourceDirectory/kotlin")
}
// Correct:
android.sourceSets.named("main") {
kotlin.directories += "additionalSourceDirectory/kotlin"
}
For generated sources, use the Variant API:
androidComponents.onVariants { variant ->
variant.sources.kotlin!!.addStaticSourceDirectory("additionalSourceDirectory/kotlin")
}
Per-Module Migration Strategy
For large projects, migrate module-by-module:
- Disable globally:
android.builtInKotlin=falseingradle.properties - Enable per migrated module by applying the opt-in plugin:
plugins { id("com.android.built-in-kotlin") version "AGP_VERSION" } - Follow Steps 1-4 for that module
- Once all modules are migrated, remove
android.builtInKotlin=falseand allcom.android.built-in-kotlinplugins
Optional: Disable Kotlin for Non-Kotlin Modules
For modules that contain no Kotlin sources, disable built-in Kotlin to save build time:
android {
enableKotlin = false
}
Opt-Out (Temporary)
If blocked by plugin incompatibilities, opt out temporarily:
# gradle.properties
android.builtInKotlin=false
android.newDsl=false # also required if using new DSL opt-out
Warning: Ask the user if they want to opt out, and if so, remind them this is a temporary measure.
Plugin Compatibility
See references/PLUGIN-COMPATIBILITY.md for the full compatibility table with known compatible versions, opt-out flag workarounds, and broken plugins.
Before migrating, inventory all plugins in the project and check each against that table. If any plugin is broken without workaround, inform the user. If plugins need opt-out flags, add them togradle.properties and note them as temporary workarounds.
Gradle Properties Default Changes
AGP 9.0 changes the defaults for many Gradle properties. Check gradle.properties for any explicitly set values that may now conflict.
Key changes:
| Property | Old Default | New Default | Action |
|---|---|---|---|
android.uniquePackageNames | false | true | Ensure each library has a unique namespace |
android.enableAppCompileTimeRClass | false | true | Refactor switch on R fields to if/else |
android.defaults.buildfeatures.resvalues | true | false | Enable resValues = true where needed |
android.defaults.buildfeatures.shaders | true | false | Enable shaders where needed |
android.r8.optimizedResourceShrinking | false | true | Review R8 keep rules |
android.r8.strictFullModeForKeepRules | false | true | Update keep rules to be explicit |
android.proguard.failOnMissingFiles | false | true | Remove invalid ProGuard file references |
android.r8.proguardAndroidTxt.disallowed | false | true | Use proguard-android-optimize.txt only |
android.r8.globalOptionsInConsumerRules.disallowed | false | true | Remove global options from library consumer rules |
android.sourceset.disallowProvider | false | true | Use Sources API on androidComponents |
android.sdk.defaultTargetSdkToCompileSdkIfUnset | false | true | Specify targetSdk explicitly |
android.onlyEnableUnitTestForTheTestedBuildType | false | true | Only if testing non-default build types |
Check for and remove properties that now cause errors:
android.r8.integratedResourceShrinking— removed, always onandroid.enableNewResourceShrinker.preciseShrinking— removed, always on
Pure Android Tips
For non-KMP Android modules upgrading to AGP 9.0, follow the "Built-in Kotlin Migration" steps above, then review the "Gradle Properties Default Changes" table. Additional changes:
- Review new DSL interfaces —
BaseExtensionis removed; useCommonExtensionor specific extension types - Java default changed from Java 8 to Java 11 — ensure
compileOptionsreflects this
Verification
After migration, verify with the checklist. Key checks:
./gradlew buildsucceeds with no errors- All platform targets build successfully (Android, iOS via
xcodebuild, Desktop, JS/Wasm) ./gradlew :shared:allTestsand Android unit tests pass- No
com.android.libraryorcom.android.applicationin KMP modules - No
org.jetbrains.kotlin.androidin AGP 9.0 modules - Source sets use correct names (
androidMain,androidHostTest,androidDeviceTest) - No deprecation warnings about variant API or DSL
Common Issues
See references/KNOWN-ISSUES.md for details. Key gotchas:
KMP Library Plugin Issues
- BuildConfig unavailable in library modules — use DI/
AppConfigurationinterface, or use BuildKonfig or gradle-buildconfig-plugin for compile-time constants - No build variants — single variant architecture; compile-time constants can use BuildKonfig/gradle-buildconfig-plugin flavors, but variant-specific dependencies/resources/signing must move to app module
- NDK/JNI unsupported in new plugin — extract to separate
com.android.librarymodule - Compose resources crash without
androidResources { enable = true } - Consumer ProGuard rules silently dropped if not migrated to
consumerProguardFiles.add(file(...))in new DSL - KSP requires version 2.3.1+ for AGP 9.0 compatibility
AGP 9.0 General Issues
- BaseExtension removed — convention plugins using old DSL types need rewriting to use
CommonExtension - Variant APIs removed —
applicationVariants,libraryVariants,variantFilterreplaced byandroidComponents - Convention plugins need refactoring — old
android {}extension helpers are obsolete
Reference Files
- DSL Reference — side-by-side old→new DSL mapping
- Version Matrix — AGP/Gradle/KGP/Compose/IDE compatibility
- Plugin Compatibility — third-party plugin status and workarounds
FAQ
What does the kotlin-tooling-agp9-migration skill do?
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.
How do I install kotlin-tooling-agp9-migration?
Run npx skills add https://github.com/kotlin/kotlin-agent-skills --skill kotlin-tooling-agp9-migration in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/kotlin-tooling-agp9-migration/ (personal) or .claude/skills/kotlin-tooling-agp9-migration/ (project).
Which AI agents can use kotlin-tooling-agp9-migration?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is kotlin-tooling-agp9-migration safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains kotlin-tooling-agp9-migration?
It is published by kotlin in kotlin/kotlin-agent-skills, and it is an official skill from the maker of the technology it covers. It has 2,174 recorded installs.
More from kotlin/kotlin-agent-skills
kotlin-tooling-java-to-kotlin
kotlin/kotlin-agent-skills
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, Jackson, Micronaut, Quarkus, Dagger/Hilt, RxJava, JUnit, Guice, Retrofit, and Mockito.
kotlin-tooling-cocoapods-spm-migration
kotlin/kotlin-agent-skills
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.
kotlin-backend-jpa-entity-mapping
kotlin/kotlin-agent-skills
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 (Java Persistence API) entities, diagnosing N+1 or LazyInitializationException, placing indexes and uniqueness rules, or preventing Kotlin-specific bugs such as data class entities and broken equals/hashCode.
kotlin-tooling-immutable-collections-0-5-x-migration
kotlin/kotlin-agent-skills
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, removeAt→removingAt, set→replacingAt, put→putting, clear→cleared, …) and deprecates the old names (WARNING, with ReplaceWith). Driven by the compiler: bump the version, recompile, and apply the rename each deprecation warning names. Use when the user mentions kotlinx.collections.immutable 0.5.x, PersistentList migration, "Use adding() instead", KEEP-0459, or sees deprecation warnings from kotlinx.collections.immutable.
kotlin-tooling-native-build-performance
kotlin/kotlin-agent-skills
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 toolchain, KSP or other generated code on the native path, transitiveExport usage, or asks for a local-development versus CI build performance plan.
kotlin-tooling-kotlin-toolchain
kotlin/kotlin-agent-skills
Open the skill to read its SKILL.md instructions.
Popular mobile skills
design-mobile-apps
designed-by-ai/skills
Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.
ios-design
uizze.sh
Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.
vercel-react-native-skills
vercel-labs/agent-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
animate-expo
emilkowalski/skills
Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
firebase-remote-config-basics
firebase/agent-skills
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.