Cloning a Mobile App with LLM Agents at Low Cost: A Complete Clean-Room Reconstruction
This article describes how an LLM agent workflow rebuilt a full mobile app from its public interface. The author used a clean-room method, observing only visible screens and behavior, and rewrote the native Android client and the server from scratch. It covers the acceptance criteria, ADB-based device control, dual-channel UI parsing, specification documents, verification results, and lessons learned. The experiment took about 7 hours and roughly 21 CNY (Chinese yuan) in model API costs.
1. Background and Goals
Last weekend I shared a workflow that used an LLM agent to build a content studio from scratch. Several readers asked in the comments whether the same approach could go further and clone a complete mobile app.
So I ran an experiment. I chose an AI generation product as the target. It can generate images and videos, and it supports features such as video editing and video extension. Using the clean-room approach, I started from the public interface and observable behavior, then rewrote the native client and server code from scratch. The goal was a one-to-one match in both functionality and visual design.
The experiment took about 7 hours, and the LLM API calls cost about 21 CNY. First, a clarification: cloning a mobile app does not necessarily require decompilation or dynamic injection. The public interface already exposes a large amount of information that can be parsed.
2. Core Methodology: Why Clean-Room?
The core principle of clean-room cloning is to observe only publicly visible interfaces and behavior. Do not access the original code, do not decompile it, and do not capture private protocols. This approach has three benefits:
- Compliance: It does not touch protected native code or binary resources. What gets replicated is the interaction logic and product form, which is a common and legitimate way to study a product.
- Controlled cost: It avoids the effort of learning and debugging a decompilation toolchain. All information comes from the output a user sees on a real device.
- Fit with agent workflows: LLM agents work best in an observe, reason, generate, and verify loop. The clean-room approach provides a complete observation surface for that loop.
The whole process follows a closed loop of investigate, rebuild, verify, and deliver. In practice, this becomes a five-step framework.
3. The Five-Step Framework
Step 1: Clone Grading (L0–L5)
Split the cloning target into six levels so that “done” has a clear meaning:
- L0: Static visual restoration. The UI matches screenshots only.
- L1: The UI is interactive, but the data is static mock data.
- L2: Core flows work end to end, and some features are placeholders.
- L3 (default acceptance line): Output parity. The app makes real LLM calls, the generated results are on par with the original, and no hardcoded fake data is used.
- L4–L5: Full alignment of account systems, billing, and scale.
Setting the acceptance line up front matters. Many cloning projects stop at L1. The UI looks right, but the functionality is an empty shell. Defining acceptance criteria early keeps the agent from producing many meaningless fake implementations.
Step 2: Direct ADB Device Connection
Enable USB debugging on the phone and connect it to a computer. The agent then takes control of the device through terminal commands.
adb devices # confirm the device is onlineadb shell dumpsys window | grep mCurrentFocus # get the current foreground app
In a loop, the agent can autonomously open the target page, trigger interactions, and observe the responses. The key is giving the agent the ability to remotely control a real device. Relying on manual screenshots breaks the automation loop and slows the process.
Step 3: Dual-Channel Parsing: Semantic Tree and Screenshots
Screenshots alone do not give the model accurate enough layout information. The control tree alone misses visual details. So the workflow uses two channels:
- Structure channel:
uiautomator dumpexports the control semantic tree, which provides each control’s type, text, ID, and bounding box coordinates. - Visual channel:
screencapcaptures a high-resolution screenshot. A multimodal model extracts the design language, including the color scheme, corner radius, spacing, font size, and icon style.
adb shell uiautomator dump /sdcard/ui.xmladb pull /sdcard/ui.xmladb exec-out screencap -p > screen.png
Cross-checking the two sources gives higher UI reconstruction accuracy than either source alone.
Step 4: Structured Specification Output
Turn the observations into two structured documents. These documents become the single source of truth for the rebuild:
- Per-screen UI difference table: Records each screen’s layout structure, control parameters, and state variants, such as loading, empty, and error states.
- Behavior audit table: Records state transitions after each interaction. For example, it notes which polling steps follow a “generate video” action, how results are kept by version, and how each output is linked to its source image.
This step is the core of the whole clone. Without a specification, the agent writes code by guesswork, and the implementation drifts. With one, the rebuild becomes construction according to a spec.
Step 5: Native Client and Server Rebuild with Same-Device Verification
- Client: A native Android app written in Kotlin, implemented screen by screen against the specification.
- Server: A Python backend connected to general-purpose LLM inference capabilities, including image generation, video generation, and video extension. These are implemented through common multimodal model API categories.
- Verification: Install the rebuilt app on the same physical device, run it side by side with the original, and compare screen by screen and feature by feature.
4. Effect Verification: More Than Looking Similar
In the verification phase, I built a high-fidelity comparison set. It covers core screens such as the home page, project page, image editing, and parameter settings. More importantly, I verified functionality:
- Real model calls: Generation runs through a real LLM inference pipeline, not placeholder images.
- Long-task completeness: The video extension feature produced a complete 16-second clip that plays through in full. This confirmed the polling and task state machine logic.
- Versions and provenance: Multiple generated versions were retained correctly, and their derivation relationships with the source image are clearly labeled.
All three items meet the L3 acceptance line.
5. Pitfalls and Reusable Assets
I ran into several pitfalls along the way. I packaged the lessons into an app-cloning skill package. The key points are:
- Prefer the semantic tree for slow interactions: Loading animations and screenshot noise during polling make screenshots unreliable. The control tree is more stable.
- Build the state machine first: Map the state transitions in the behavior audit table before writing any UI. This can reduce rework by more than 50%.
- Automate verification: Write scripts that compare key screenshots from two same-device runs. Leave only the final judgment to a human.
- Abstract the server: Implement the model call layer as a replaceable adapter, so you can switch between different multimodal providers.
I also published the cloned client and server code, along with the skill package, to a code hosting platform for learning and further development. Using this skeleton, building a similar AI generation product is technically feasible.
6. Final Thoughts
The main value of this experiment is not the 21 CNY cost figure. It validates a general path: LLM agents, real-device automation, the clean-room methodology, and specification-driven acceptance. This path can systematically lower the barrier to rebuilding mobile products. For independent developers, understanding this framework matters more than any single output. The same approach also applies to rebuilding web and desktop products. I wish every developer who tries it success as they take their products overseas.
