A Low-Cost Practical Guide to Clean-Room Rebuilding of Mobile Apps

    This guide explains how to rebuild a mobile app's core flows through clean-room observation instead of reverse engineering. It breaks the process into five steps: fidelity grading, direct device connection over ADB, semantic tree and screenshot parsing, a specification checklist, and native plus server-side rebuilding with on-device acceptance testing. You will also find the cost and risk boundaries, including a reported run of about 7 hours and 21 RMB in compute and API usage for a medium-complexity app on a single machine.

    1. Background: Why Rebuilding an App Is More Manageable Than It Looks

    In app development, a common request comes up: you see a mobile product with smooth interactions and polished visuals, and you want a runnable version with matching features and a close user experience, for learning, validating an idea, or further development. The first instinct is often to decompile, capture network traffic, or reverse engineer the protocol. But those approaches carry compliance risks and burn effort on details unrelated to business value.

    A safer approach is the clean room: observe only the publicly visible UI and interaction results, never touch the internal implementation, and write native code and server-side logic from scratch. Its value is turning “does it look the same” into measurable, acceptance-testable engineering work, rather than repeatedly tweaking styles by feel.

    This article abstracts the whole process into five steps: fidelity grading → direct device connection → UI semantics and screenshot parsing → specification checklist → rebuilding and on-device acceptance. The process can be carried out with AI coding tools working alongside a command-line terminal. In a measured run on a single machine targeting one app, a medium-complexity app’s core flow was completed with about 7 hours and 21 RMB in compute and API costs.

    2. Step 1: Grade Fidelity First, and Decide How Close the Rebuild Should Be

    The most common reason a rebuild fails is not insufficient skill but an unclear target. Fidelity can be split into six levels, L0 to L5:

    • L0: information architecture matches, and pages can navigate;
    • L1: static layout matches, with control positions and hierarchy aligned;
    • L2: visuals match, including colors, corner radii, font sizes, and spacing;
    • L3: behavior matches, where key interactions produce the same state changes and results (the default target; static fake data is not accepted as a shortcut);
    • L4: edge cases match, including error states, empty states, loading states, and permission-denied states;
    • L5: performance and accessibility match, including scroll frame rate, launch time, and accessibility labels.

    Grading matters because it constrains scope. Locking the default at L3 means every screen must be wired to real logic, and hard-coded list data is not allowed. It also means explicitly listing what is out of scope for this round, such as a complex recommendation algorithm, so scope creep does not push costs out of control.

    3. Step 2: Connect a Real Device Directly So the Tools Can “See” the Phone

    No extra reverse-engineering framework is required. Just enable USB debugging on the phone, connect it to the computer with a data cable, and the AI coding tool can take over the device by running debugging commands through the terminal. Common capabilities include:

    1. # Confirm the device is connected
    2. adb devices
    3. # Export the control structure of the current screen (semantic tree)
    4. adb shell uiautomator dump
    5. adb pull /sdcard/window_dump.xml
    6. # Capture a screenshot of the current screen for visual comparison
    7. adb shell screencap -p /sdcard/screen.png
    8. adb pull /sdcard/screen.png
    9. # Inject taps, swipes, and text input directly
    10. adb shell input tap 540 1200
    11. adb shell input swipe 540 1500 540 600
    12. adb shell input text "hello"

    The key to this combination is repeatability: capture the semantic tree and a screenshot before and after every step, forming a replayable observation sequence. Every later difference can then be traced to a specific step.

    4. Step 3: Parse the Semantic Tree and Screenshots Through Two Channels

    Screenshots alone lose structure, and the semantic tree alone loses visuals. The two streams must be merged:

    1. The semantic tree provides control types, text, clickable state, and exact coordinates, used to rebuild the layout hierarchy and interaction hit areas;
    2. Screenshots provide colors, corner radii, shadows, font hierarchy, and icon style, used to restore visual detail;
    3. Normalize coordinates to a design baseline resolution to avoid misalignment across different screen sizes;
    4. For list-based screens, additionally record scroll direction and pagination trigger points, which are key to rebuilding the “feel.”

    A sample parsing output can be structured as:

    1. {
    2. "screen": "home",
    3. "nodes": [
    4. {"type": "Button", "text": "Generate", "bounds": [0.12, 0.86, 0.42, 0.92], "clickable": true}
    5. ],
    6. "style": {"primary": "#1A73E8", "radius": 12, "titleSize": 20}
    7. }

    5. Step 4: Turn Observations into an Executable Specification Checklist

    This step converts “seeing” into “doing” and produces two tables:

    • A per-screen UI difference table: screen name, control list, visual parameters, differences between the current implementation and the target, and priority;
    • A behavior audit table: trigger action, preconditions, state changes, result feedback, and failure branches.

    The behavior audit table is especially important because it determines whether L3 can be reached. For an operation such as “extend video,” for example, it must record: the button enters a loading state after the tap, which visible options the request parameters include, how the duration changes on success, how multiple versions are retained, and how ownership of the original image is marked. Once these are written down as items, the rebuilding phase is just a matter of implementing them one by one.

    6. Step 5: Rebuild the Native Client and Server, Then Run On-Device Acceptance

    Use a declarative UI framework to describe the UI on the native side, and a general-purpose scripting language to provide endpoints on the server side, with the two communicating through a clearly defined API contract:

    1. # Sample server API contract (structure only, not a specific product API)
    2. @app.post("/api/task")
    3. def create_task(req: TaskRequest):
    4. task = store.create(req) # Persist, keeping version and original-image ownership
    5. queue.publish(task.id) # Generate asynchronously to avoid blocking
    6. return {"taskId": task.id, "status": "pending"}

    Acceptance must be done on the same device with an on-device comparison: replay the operation sequence item by item from the behavior audit table, capture the semantic tree and a screenshot at each key point, and compare side by side with the target app. File differences by L0–L5; any difference below L3 counts as incomplete and cannot be dismissed on the grounds that “the data is different.”

    7. Lessons Learned: Package the Process into a Reusable Skill

    Getting through one run does not make it reusable. Turn the process above into a skill package containing a grading template, collection scripts, parsing rules, a difference-table template, an acceptance checklist, and a directory skeleton. A newcomer only needs to swap in the target app to get started. On the engineering side, it also helps to open-source a runnable native client and server skeleton so others can adapt it into similar content-generation apps.

    8. Cost and Risk Boundaries

    Costs come mainly from model calls and screenshot parsing. To control them, reduce collection frequency, cache parsing results per screen, and do visual comparison only at key points. On risk, three boundaries must be clear: use only publicly visible information, do not copy any protected assets or code, and use the rebuild results only for learning and validating your own product. Holding these three lines is what makes clean-room rebuilding a sustainable engineering method rather than a one-off shortcut.