Clean-Room Mobile App Cloning: LLM-Driven Automated Interaction and UI Reconstruction

    This article presents a clean-room approach to rebuilding a mobile app without decompiling it, using ADB-based UI capture, LLM-assisted specification generation, native client and lightweight backend implementation, and same-device A/B acceptance. It covers a six-level cloning scale, UI diff and behavior audit artifacts, a 7-hour AI tool case study, and common pitfalls with mitigation strategies.

    In mobile app development, how can a team quickly build an in-house version with equivalent functionality and a similar interface when a mature product already exists? Traditional approaches often rely on decompilation or network packet capture to reverse-engineer business logic, but this introduces compliance risks and can easily lead to code-level plagiarism. This article proposes a cleaner path: clean-room cloning. Without touching the target app’s internal implementation, it rewrites native client code and backend services from scratch based only on publicly observable interfaces and interaction results. The entire workflow is assisted by an LLM-driven automated toolchain, referred to here as an “intelligent agent,” which reduces manual involvement to a very low level.

    1. Define the Clone Level First: A Capability Ladder from L0 to L5

    Before any cloning project starts, the target level must be defined. Not every project needs pixel-perfect reproduction, and blindly pursuing perfection can cause costs to spiral. It is useful to divide cloning depth into six levels:

    • L0: Static screenshots only, with no interaction capability. Typically used for product research or competitive analysis.
    • L1: Page navigation and basic click responses are implemented, but data is hardcoded static content.
    • L2: Real backend APIs are connected and page data loads dynamically, but some interaction logic is simplified.
    • L3: Features and visual effects are highly consistent, interaction behaviors such as swiping, long pressing, and dragging are fully mapped, and fake data is not used.
    • L4: On top of L3, exception handling and edge states such as empty data, weak network, and load failure are added to form a complete state machine.
    • L5: Production-grade quality, including performance optimization, security hardening, multi-device adaptation, and observability.

    Most “clone” requirements can be satisfied at L3 for demos or secondary development. The case in this article uses L3 as the default delivery standard while preserving interfaces for extending to L4.

    2. Transparent Collection: ADB Direct Device Access and Semantic Tree Parsing

    Without decompilation, how can the target app’s page structure and interaction parameters be obtained? The answer is to use the Android Debug Bridge (ADB) and Android accessibility capabilities. The intelligent agent takes over a physical device with USB debugging enabled through terminal commands and obtains two key types of data:

    1. Control tree: Running the uiautomator dump command makes the system export the current screen’s View hierarchy, control IDs, text content, coordinate bounds, clickable attributes, and other information as XML. This “semantic tree” is effectively a logical map of the app UI. It contains no implementation code, but it fully describes the interface elements that users can perceive.
    2. Screenshots: The screencap command captures a bitmap of the current screen for extracting visual features such as colors, rounded corners, shadows, and font sizes. By overlaying screenshots with the semantic tree, the mapping between “visual pixels” and “logical controls” can be established precisely.

    Collection is not a one-time process. An exploration script must be designed so that the intelligent agent automatically simulates clicks, swipes, text input, and other operations to traverse every secondary page and popup state of the app. Each time a new interface change is triggered, the control tree and screenshot are recorded synchronously, along with the operation sequence and the state difference before and after the action. The result is an “interaction trajectory” dataset that provides raw material for generating normalized specifications later.

    3. From Raw Data to Normalized Specifications: Diff Tables and Behavior Audits

    Raw collected data is messy and must be transformed into technical documents that engineers can execute against. Two structured outputs are introduced here:

    • Per-screen UI diff table: Records control position deviation, size ratio, color value differences, text font size, and font weight by page. For example, the original home page’s navigation bar height may be 128dp, while the cloned version renders it at 132dp. The diff table explicitly marks this deviation and the interaction hot zones it may affect. For visual reproduction, this table is the sole basis for quality inspection.
    • Behavior audit table: Records the state changes caused by each operation. For example, “tap image thumbnail → bottom toolbar appears → toolbar contains three buttons (edit, extend, share) → tap edit to enter a secondary page.” Each action includes preconditions, triggering control, expected result, and actual navigation target. The behavior audit table is the core asset for verifying functional consistency, ensuring that the cloned version produces the same output flow for the same input.

    Generating these tables can be fully automated. The intelligent agent uses the collected semantic trees and screenshots, combined with predefined business rules, to generate drafts automatically. Humans only need to review and correct a small number of ambiguous items, such as dynamic control ID mapping and popup animation duration.

    4. Rebuild and Acceptance: Parallel Native Client and Backend Development

    Once the normalized specifications are finalized, implementation begins. To achieve L3-level “effect consistency,” a native technology stack is recommended over a cross-platform framework so that animation curves and touch feedback can be controlled precisely. The client uses Kotlin to build a native Android app, while the backend uses Python to build a lightweight API gateway responsible for AI inference tasks such as image generation and video editing. The key points are:

    • Interface contract first: Based on the behavior audit table, define the request/response models for all RESTful APIs first. For example, /v1/video/extend receives a video file and an extension duration parameter and returns the URL of the newly generated video. The backend can be implemented directly with Python’s FastAPI or Flask, using mock data to run the full chain first.
    • Client-driven development: The client builds layouts screen by screen according to the UI diff table and binds APIs with Retrofit or Ktor. No business logic is hardcoded; all state comes from the backend. For long-running operations such as video generation, coroutines and Flow are used to manage asynchronous tasks and keep the UI smooth.
    • Same-device acceptance: Install the original app and the cloned version on the same physical device. An ADB script drives both apps under the same input sequence and compares screenshots and control trees after each operation. If the difference exceeds a threshold, such as pixel color difference >10 or control coordinate offset >20dp, the test is automatically marked as failed. This “A/B same-device test” greatly improves acceptance efficiency and does not rely on manual visual comparison.

    5. Case Study: Cloning the Core Features of an AI Generation Tool

    To verify the feasibility of the approach, the author selected an AI creation app with capabilities such as text-to-image, image-to-video, and video extension as the target. The full clone took about 7 hours, with a cost of approximately CNY 21, mainly for cloud function calls and pay-as-you-go GPU inference. The process was as follows:

    1. Level definition and collection (1.5 hours): An ADB script automatically traversed eight core pages, including the home page, project list, image editing page, video generation progress page, and settings page, collecting more than 40 screenshots and corresponding control trees.
    2. Specification generation (1 hour): The intelligent agent automatically generated three diff tables and five behavior audit tables. Two dynamic control mapping errors were manually corrected.
    3. Backend rebuild (2 hours): Open-source models were reused to write inference services for image generation and video frame interpolation. These were packaged as a Python service and deployed on a container instance, exposing a unified HTTP API.
    4. Client rebuild (2 hours): Kotlin was used to build the bottom navigation framework, and the list, detail, and editing pages were implemented according to the diff tables. For video extension, the frontend only needs to show a progress bar and poll the backend status.
    5. Acceptance (0.5 hours): The same-device test script completed the full chain of “upload image → generate video → extend by 4 seconds → re-output.” Pixel-level comparison showed that key control deviation was less than 5%, and functional behavior fully matched the original case.

    Final deliverables included a complete client project, backend code, automated collection and test scripts, and detailed cloning process documentation. The result was directly used for secondary development, where models can be replaced, filters added, or more media capabilities integrated.

    6. Pitfalls and Mitigation Strategies

    • Dynamic ID interference: Some apps’ control IDs change across build versions, causing semantic tree mappings to fail. The solution is to use text content or parent node structure for relative positioning rather than relying on absolute IDs.
    • Popup and Toast interference: Ad popups or system notifications can interrupt automated exploration. Notifications can be forcibly disabled in ADB commands, and wait conditions can be set in scripts, such as waiting for a control to disappear.
    • Backend concurrency pressure: Video AI inference is usually a long-running operation (10–30 seconds), so an asynchronous task queue is needed. It is recommended to use a message queue to receive requests, process them with worker processes, and return a task ID to the frontend for polling.
    • Real network traffic: During acceptance, switch to a real network to avoid fake data caused by local host mapping. Also test exception branches under weak network and airplane mode to ensure the client provides reasonable error prompts.

    7. Conclusion and Extensions

    The essence of the clean-room cloning methodology is to elevate reverse engineering from the code level to the behavior level. It does not touch any protected intellectual property and reconstructs product functionality only by observing input/output patterns. With LLM-driven intelligent agents, the workflow is already close to the upper limit of automation: developers only need to provide the target device and acceptance criteria, and the remaining work is handled by an “investigate–rebuild–verify–deliver” loop.

    For teams that want to quickly build products in the same category, this approach can significantly reduce initial exploration costs. The framework is also applicable to app migration, accessibility adaptation, automated testing, and other areas. In the future, with the development of multimodal models and reinforcement learning, intelligent agents may directly understand visual interfaces and generate interaction logic, further compressing the cloning cycle. Regardless of how the technology evolves, clear normalized documentation and strict acceptance mechanisms will always be the foundation of quality assurance.