migrate-xml-views-to-jetpack-compose
Ce qu’il fait
Ce skill guide la conversion d'une mise en page XML historique d'une application Android en Jetpack Compose. Il conserve le même aspect et vérifie le résultat avant de supprimer l'ancien XML. Il s'adresse aux développeurs Android qui modernisent des écrans anciens.
Quand l’utiliser
- ✓Quand vous avez un écran Android ancien construit avec des vues XML et voulez le passer en Jetpack Compose.
- ✓Quand vous voulez choisir la mise en page XML la plus adaptée à une migration en premier.
- ✓Quand vous avez besoin d'un plan et de contrôles visuels pour que le nouvel écran Compose corresponde à l'ancien.
Lien du skill
https://github.com/android/skills/blob/main/jetpack-compose/migration/migrate-xml-views-to-jetpack-compose/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Migre mon écran de réglages des vues XML vers Jetpack Compose et garde le même aspect.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Le skill suit un processus en dix étapes, de l'analyse de la mise en page au paramétrage de Compose et du thème. Il capture l'ancien écran, construit la version Compose, la vérifie visuellement, puis remplace les anciennes utilisations et supprime le XML.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
This skill guides through the process of migrating an existing Android XML View to Jetpack Compose. It performs a stable, safe and visually consistent transition by following a structured, 10-step methodology. This skill migrates UI (XML to Jetpack Compose) only.
Objective
To systematically convert a single legacy XML layout into modern, declarative Jetpack Compose UI while maintaining pixel-perfect visual parity and functional integrity.
Summary of the 10-step migration process
- Identify the optimal XML candidate for migration
- Analyze the project and layout
- Create a plan
- Capture the XML View UI
- Set up Compose dependencies and compiler
- Set up Compose theming
- Migrate the XML layout to Compose
- Validate the migration
- Replace usages
- XML code removal
Detailed steps
Step 1: Identify the optimal XML candidate for migration
If the user has explicitly specified a target XML layout, proceed to Step 2. Otherwise, analyze the codebase to identify the best candidate for migration by following the logic in references/identify-optimal-xml-candidate.md.
Step 2: Analyze the project and layout
Analyze the identified XML View's structure, hierarchy, and implementation details. Use references/analysis-of-the-project-and-layout.md to guide your technical audit of the layout and surrounding project context.
Step 3: Create a plan
Using the outputs and analysis done in the Step 1 and 2, generate a step-by-step plan for the migration. If you support user interaction, present to the user and ask for approval before proceeding. If user interaction is not supported, proceed to Step 4 following the generated plan.
Step 4: Capture the XML View UI
IF you support user interaction, ask the user to upload a screenshot of the XML View UI or provide an absolute path to a file. Use this image as a visual reference for the layout migration in Step 7. ELSE IF you are able to run an Android emulator, locate an existing screenshot test for the XML candidate. If none exists, create one using the existing project testing framework. If no framework exists, use UI Automator or Espresso to create a screenshot test with minimum required setup. Run the test and take a baseline screenshot of the XML UI. ELSE proceed to Step 5.
Step 5: Set up Compose dependencies and compiler
Check build.gradle or libs.versions.toml for Compose dependencies and
compiler setup. If missing, use
Setup Compose Dependencies and Compiler.
Run a sync to ensure dependencies resolve without errors.
Step 6: Set up Compose theming
If the project already has Compose theming set up, proceed to Step 7. If Compose theming is missing, initialize it. For Material-based projects, follow Material 3 migration guidelines. For custom design systems, apply expert judgment to migrate XML theming and match existing styles. Constraints: Do not migrate the entire theme. Implement only the minimum theming required for the specific XML candidate. Maintain original XML themes for interoperability. Maintain existing project code conventions, patterns, names and values.
Step 7: Migrate the XML View to Compose
Convert the XML candidate to Jetpack Compose code, referencing references/xml-layout-migration.md and the image from Step 4. You must include a Compose Preview for the newly created composable to facilitate visual verification.
Step 8: Replace usages
Replace the usages of the migrated XML layout to use the new Compose component.
- To add Compose in Views, use Compose in Views.
- To add Views in Compose, use Views in Compose.
Step 9: Validate the migration
Compare the baseline screenshot image from Step 4 with the rendered Compose Preview of the new composable. Ignore string content; focus on layout and styling. Iterate on the Compose code until visual parity is achieved. Once verified, write a Compose UI test for the new composable.
Step 10: XML code remo
Questions fréquentes
Migre-t-il toute mon application d'un coup ?
Non. Il migre une mise en page XML à la fois, et vous pouvez choisir la mise en page ou laisser le skill en sélectionner une.
Comment vérifie-t-il le résultat ?
Il capture l'ancien écran et compare le nouvel écran Compose avec lui pour confirmer la correspondance visuelle.
Modifie-t-il la logique de l'application ?
Non. Le skill ne migre que l'interface utilisateur.
Détails
Description originale de l’auteur
Provides 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.
repo: android/skills
Popularité
- Étoiles GitHub
- 10k
- Position au classement
- #11922
- Licence
- Apache-2.0
- Mis à jour
- 29/10/2026
Commentaires
- …
Autres skills de ce dépôt
agp-9-upgrade
10kAide votre agent à migrer une application Android vers Android Gradle Plugin 9 et à corriger les changements incompatibles. Hors Kotlin Multiplatform.
camerax
10kAide votre agent à créer des fonctions de caméra Android avec CameraX : vidéo, commandes matérielles, ML Kit et effets Media3.
android-for-cars-parked-apps
10kAide votre agent à adapter une application vidéo, de jeu ou de navigateur Android pour qu'elle tourne sur Android Auto ou Automotive.
appfunctions
10kAide votre agent à exposer les parcours clés d'une application Android sous forme d'AppFunctions, que les agents IA et la voix peuvent exécuter.
Skills similaires
android-clean-architecture
280kPermet à votre agent d'organiser efficacement les projets Android. Il structure le code pour faciliter la maintenance et le développement de nouvelles fonctionnalités.
compose-multiplatform-patterns
280kAide votre agent à utiliser les patterns Compose Multiplatform et Jetpack Compose dans les projets KMP : état, navigation, thèmes et performances.
dart-flutter-patterns
280kPermet à votre agent d'écrire du code pour les applications Dart et Flutter. Il utilise des patterns modernes pour des apps robustes et faciles à gérer.