Porting Declarative UI to HarmonyOS: A Heuristic-guided LLM Approach
This paper presents ArkTrans, a heuristic-guided LLM approach that automatically translates declarative UI code from Android and iOS to HarmonyOS's ArkUI by constructing language-specific skeletons and applying post-fixing rules, achieving up to 90.67% successful compilation with high visual fidelity compared to direct prompting methods.
Original paper dedicated to the public domain under CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a beautifully decorated house built with Kotlin Jetpack Compose (the style used for modern Android apps) or SwiftUI (the style for modern iPhone apps). Now, you want to move this house into a brand-new neighborhood called HarmonyOS, which uses a completely different architectural style called ArkUI.
The problem? The construction workers (in this case, the AI models or "Large Language Models") have never built a house in the HarmonyOS neighborhood before. If you just tell them, "Copy this house over," they get confused. They try to use Android or iPhone tools in the HarmonyOS zone, resulting in a building that looks like a chaotic mess of mismatched bricks and won't even stand up (it won't compile).
This paper introduces a new tool called ArkTrans to solve this problem. Think of ArkTrans not as a magic copy-paste button, but as a smart architectural foreman who guides the AI through a four-step construction process.
The Four-Step Construction Plan
1. The Blueprint Scan (Metadata Extraction)
First, ArkTrans doesn't just look at the finished house; it scans the original blueprints. It breaks the house down into a logical list of parts: "Here is a door, here is a window, here is a wall, and this wall is made of red bricks." It creates a clean, organized list (a "UI tree") that ignores the confusing construction jargon specific to Android or iOS.
2. The Skeleton Build (Skeleton Construction)
Next, instead of asking the AI to build the whole house from scratch, ArkTrans builds a skeleton. It takes the list of parts and assembles a basic frame using HarmonyOS rules.
- Analogy: Imagine the AI is a painter. ArkTrans hands them a pre-built wooden frame with the walls already in the right places. The AI just needs to fill in the details (paint, textures, decorations) rather than figuring out where the walls should go. This prevents the AI from getting lost.
3. The Guided Painting (LLM-driven Translation)
Now, the AI steps in to fill in the details. Because it has the skeleton and a specific "cheat sheet" (a one-shot example showing how to translate a specific part), it knows exactly how to paint the walls and hang the doors using HarmonyOS rules. It's like giving the painter a sample of the correct paint color and a picture of the finished room to copy.
4. The Safety Inspection (Post-Fixing)
Even with a skeleton and a guide, the AI might still make small mistakes, like using a screw meant for wood on a metal beam, or forgetting to tighten a bolt. ArkTrans runs a final automated inspection. It has a checklist of common errors (like "Don't use this specific Android command here") and automatically fixes them before the house is handed over.
The Results: Does It Work?
The researchers tested this by trying to move 100 different "rooms" (UI pages) from Android and iOS to HarmonyOS.
- Without ArkTrans: If they just asked the AI to "translate" the code directly, 0% of the rooms were buildable. The AI got stuck, and the code was full of errors. It was like trying to build a house with the wrong tools; nothing worked.
- With ArkTrans: The success rate skyrocketed.
- For Android-to-HarmonyOS moves, 90.67% of the rooms were successfully built and stood up.
- For iOS-to-HarmonyOS moves, 53.33% were successful.
- Not only did they stand up, but they also looked very similar to the original rooms (high "visual fidelity").
The Key Takeaway
The paper claims that the biggest hurdle isn't just that the AI is "dumb"; it's that the AI is unfamiliar with the new rules and tends to copy-paste old rules that don't work.
ArkTrans works because it doesn't rely on the AI's memory alone. Instead, it:
- Forces structure (by building the skeleton first).
- Provides examples (so the AI knows the new style).
- Cleans up mistakes (by fixing the common errors automatically).
In short, ArkTrans turns a chaotic, impossible translation task into a guided, step-by-step construction project, successfully moving digital "houses" from one operating system to another.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.