Try migrating XML View to Jetpack Compose using Android CLI skills

Try migrating XML View to Jetpack Compose using Android CLI skills

With the Android Compose First declaration, I tried out the official skill that supports migration from XML Views to Jetpack Compose. Here I will introduce the results of actually running it.
2026.08.21

This page has been translated by machine translation. View original

Since Android declared Compose First, I thought we might need to consider migrating to Jetpack Compose.
There's a skill called /migrate-xml-views-to-jetpack-compose that supports migration from XML Views to Jetpack Compose, so let me try it out.

https://developer.android.com/develop/ui/compose/migrate/migrate-xml-views-to-jetpack-compose?hl=ja


Android CLI

To run the skill, I first needed to install the skill itself from the Android CLI, so I tried running it.
Since I'm using Claude Code, I specified --agent=claude-code.

android skills add migrate-xml-views-to-jetpack-compose --agent=claude-code

When executed, the /migrate-xml-views-to-jetpack-compose skill is added to ~/.claude/skills.

What's Inside the Skill

Reading the contents written in SKILL.md, there are instructions to execute the following steps:

  1. Identifying the best XML candidates for migration
  2. Analyzing the project and layouts
  3. Creating a plan
  4. Capturing XML View UI (screenshot)
  5. Setting up Compose dependencies and compiler
  6. Setting up Compose theme
  7. Migrating XML layouts to Compose
  8. Replacing usages
  9. Verifying the migration (screenshot comparison)
  10. Deleting XML code

Details were written here:

https://developer.android.com/agents/skills/jetpack-compose/migration/migrate-xml-views-to-jetpack-compose/skill

It seems to take screenshots before migration and compare them with Compose previews after migration to verify visual consistency (Amazing).

Running the Skill

Here are the results after creating an app, implementing several Views with XML, and launching the skill:

before after
Screenshot_20260820_154952 Screenshot_20260820_154437
Screenshot_20260820_155009 Screenshot_20260820_154447
Screenshot_20260820_155015 Screenshot_20260820_154504
Screenshot_20260820_155022 Screenshot_20260820_154510
Screenshot_20260820_155037 Screenshot_20260820_154525

So close...!!

Summary

  • I think it worked roughly as described in the skill documentation
  • I was asked which screens to migrate at the start, and when I answered "all of them," migrating 5 screens took 35m 31s. (Ran with Sonnet 5)
  • The iterative adjustments using screenshot comparisons were less precise than expected
  • Screen transitions, taps, and display toggles were able to function the same as before migration
  • For production-level apps, doing everything at once doesn't seem realistic, so it seems best to do one screen at a time
  • It's not perfect, but I felt it was useful enough as a starting point for the work

Claudeならクラスメソッドにお任せください

クラスメソッドは、Anthropic社とリセラー契約を締結しています。各種製品ガイドから、業種別の活用法、フェーズごとのお悩み解決などサービス支援ページにまとめております。まずはご覧いただき、お気軽にご相談ください。

サービス詳細を見る

Share this article

AI白書