migrate-xml-views-to-jetpack-compose
できること
このスキルは、Androidアプリの古いXMLレイアウトを1つずつJetpack Composeに変換する方法を導きます。見た目は同じに保ち、古いXMLを削除する前に結果を確認します。古い画面を近代化するAndroid開発者向けです。
使う場面
- ✓XMLビューで作られた古いAndroid画面を、Jetpack Composeに移したいとき。
- ✓どのXMLレイアウトを最初に移行するのが最適かを選びたいとき。
- ✓新しいCompose画面が古い画面と一致するように、計画と視覚的な確認がほしいとき。
スキルのリンク
https://github.com/android/skills/blob/main/jetpack-compose/migration/migrate-xml-views-to-jetpack-compose/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“設定画面をXMLビューからJetpack Composeに移行し、見た目を同じに保ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、レイアウトの選択と分析から、Composeとテーマの設定まで、10段階の手順で進めます。古い画面を撮影し、Composeのバージョンを作り、視覚的に確認したうえで、古い使用箇所を置き換えてXMLを削除します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
アプリ全体を一度に移行しますか?
いいえ。XMLレイアウトを1つずつ移行します。レイアウトはあなたが選ぶか、このスキルに選ばせることができます。
結果はどのように確認しますか?
古い画面を撮影し、新しいCompose画面と比べて、見た目が一致することを確認します。
アプリのロジックは変わりますか?
いいえ。このスキルはユーザーインターフェースだけを移行します。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 10k
- ランキング
- #11922
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/29
コメント
- …
このリポジトリの他のスキル
agp-9-upgrade
10kエージェントが、AndroidアプリをAndroid Gradle Plugin 9にアップグレードし、その破壊的変更に対応できるよう支援します。マルチプラットフォームのプロジェクトは対象外です。
camerax
10kエージェントが、CameraXを使ってAndroidのカメラ機能を作れるよう支援します。動画の録画、ハードウェアの制御、ML Kit、Media3のエフェクトを含みます。
android-for-cars-parked-apps
10kエージェントが、Androidの動画、ゲーム、ブラウザのアプリを、Android AutoとAndroid Automotiveで駐車中のアプリとして動かせるように適合させるよう支援します。
appfunctions
10kエージェントが、Androidアプリの主要な作業の流れを見つけ、AIエージェントや音声コマンドが実行できるAppFunctionsとして公開できるよう支援します。
似ているスキル
android-clean-architecture
280kエージェントがAndroidプロジェクトを効率よく整理できるようにします。コードを構造化して、保守や新機能の開発をしやすくします。
compose-multiplatform-patterns
280kエージェントがKMPプロジェクトでCompose MultiplatformとJetpack Composeのパターンを使えるようにします。状態管理、ナビゲーション、テーマ設定、パフォーマンスを扱います。
dart-flutter-patterns
280kエージェントがDartとFlutterのアプリ向けのコードを書けるようにします。最新のパターンを使い、堅牢で管理しやすいアプリを作ります。