inehemiasm/AiAssistant / skills/migrate-xml-views-to-jetpack-compose
migrate-xml-views-to-jetpack-compose
VerifiedProvides a structured workflow for migrating an Android XML View to Jetpack Compose. This skill details the step-by-step process, from planning and dependency setup, to theming and layout migration, validation and XML cleanup. Use this skill when you need to migrate an XML View to Jetpack Compose in an Android project. It solves the problem of converting the UI of a legacy XML View into modern, declarative Compose components while maintaining interoperability.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.3 KB |
| references/analysis-of-the-project-and-layout.md | markdown | 3.1 KB |
| references/android/develop/ui/compose/designsystems/migrate-xml-theme-to-compose.md | markdown | 8.1 KB |
| references/android/develop/ui/compose/migrate/interoperability-apis/compose-in-views.md | markdown | 12.0 KB |
| references/android/develop/ui/compose/migrate/interoperability-apis/views-in-compose.md | markdown | 10.5 KB |
| references/android/develop/ui/compose/setup-compose-dependencies-and-compiler.md | markdown | 6.5 KB |
| references/identify-optimal-xml-candidate.md | markdown | 1.6 KB |
| references/xml-layout-migration.md | markdown | 3.5 KB |
references/android/develop/ui/compose/setup-compose-dependencies-and-compiler.md
View on GitHub## Set up the Compose Compiler Gradle plugin
For Gradle, use the Compose Compiler Gradle plugin to set
up and configure Compose.
> [!NOTE]
> **Note:** The Compose Compiler Gradle Plugin is only available from Kotlin 2.0+. For migration instructions, see ["Jetpack Compose compiler moving to the Kotlin
> repository"](https://android-developers.googleblog.com/2024/04/jetpack-compose-compiler-moving-to-kotlin-repository.html).
### Set up with Gradle version catalogs
Set up the Compose Compiler Gradle plugin:
1. In the `libs.versions.toml` file, remove any reference to the Compose Compiler.
2. In the `versions` and `plugins` sections, add the new dependency:
[versions]
kotlin = "2.3.21"
[plugins]
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
// Add this line
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
1. In the project's root `build.gradle.kts` file, add the following to the `plugins` section.
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
1. In each module that uses Compose, apply the plugin:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler)
}
The project should now build and compile if it was using the default set up. If
it had configured custom options on the Compose compiler, follow the next
section.
### Set up the Compose Compiler without Gradle version catalogs
Add the plugin to `build.gradle.kts` files associated with modules where Compose
is used:
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.3.21" // this version matches your Kotlin version
}
Add the classpath to your top-level project `build.gradle.kts` file:
buildscript {
dependencies {
classpath("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:2.3.21")
}
}
### Configuration options with the Compose Compiler Gradle Plugin
To configure the Compose compiler using the Gradle plugin, add the
`composeCompiler` block to the module's `build.gradle.kts` file at the top
level:
android { ... }
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
For the full list of available options, see the [documentation](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#compose-compiler-options-dsl).
## Set up Compose dependencies
Always use the latest Compose BOM version: `2026.05.00`.
Set the `compose` flag to `true` inside the Android [`BuildFeatures`](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/BuildFeatures)
to enable [Compose functionality](https://developer.android.com/develop/ui/compose/tooling) in Android Studio.
Add the following definition to your app's `build.gradle` file:
### Groovy
android {
buildFeatures {
compose true
}
}
### Kotlin
android {
buildFeatures {
compose = true
}
}
Add the Compose BOM and the subset of Compose library dependencies:
### Groovy
dependencies {
def composeBom = platform('androidx.compose:compose-bom:2026.05.00')
implementation composeBom
androidTestImplementation composeBom
// Choose one of the following:
// Material Design 3
implementation 'androidx.compose.material3:material3'
// or skip Material Design and build directly on top of foundational components
implementation 'androidx.compose.foundation:foundation'
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
implementation 'androidx.compose.ui:ui'
// Android Studio Preview support
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
// Optional - Add window size utils
implementation 'androidx.compose.material3.adaptive:adaptive'
// Optional - Integration with activities
implementation 'androidx.activity:activity-compose:1.13.0'
// Optional - Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0'
// Optional - Integration with LiveData
implementation 'androidx.compose.runtime:runtime-livedata'
// Optional - Integration with RxJava
implementation 'androidx.compose.runtime:runtime-rxjava2'
}
### Kotlin
dependencies {
val composeBom = platform("androidx.compose:compose-bom:2026.05.00")
implementation(composeBom)
androidTestImplementation(composeBom)
// Choose one of the following:
// Material Design 3
implementation("androidx.compose.material3:material3")
// or skip Material Design and build directly on top of foundational components
implementation("androidx.compose.foundation:foundation")
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
implementation("androidx.compose.ui:ui")
// Android Studio Preview support
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
// UI Tests
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-test-manifest")
// Optional - Add window size utils
implementation("androidx.compose.material3.adaptive:adaptive")
// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.13.0")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0")
// Optional - Integration with LiveData
implementation("androidx.compose.runtime:runtime-livedata")
// Optional - Integration with RxJava
implementation("androidx.compose.runtime:runtime-rxjava2")
}
> [!NOTE]
> **Note:** Jetpack Compose is shipped using a Bill of Materials (BOM), to keep the versions of all library groups in sync. Read more about it in the [Bill of
> Materials page](https://developer.android.com/develop/ui/compose/bom/bom).Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |