Clean-Room App Replication: Building a Low-Cost, Full-Function Clone of a Mobile AI App in Seven Hours
This engineering case study presents a clean-room approach to replicating an AI image and video generation app without relying on decompilation or packet interception. By combining ADB-based device probing, UI semantic-tree inspection, screenshot analysis, native Android development, and a FastAPI orchestration backend, the core user journey was reproduced on a real device in seven hours at an API cost of approximately RMB 21. The article explains the five-step workflow, implementation challenges, validation standards, and practical limitations of an L3-level functional clone.
In mobile product development, iteration speed often outpaces conventional engineering workflows. A common scenario is discovering an impressive AI application but lacking a fast way to validate its interaction model or build a foundation for further innovation.
The traditional options are usually time-consuming: decompiling the application, intercepting network traffic, or manually recreating every screen at the pixel level. A weekend experiment changed my view of app replication. Using a different methodology, I spent seven hours and approximately RMB 21 on API calls to reproduce the core functionality of an AI image and video generation product on a real device. The result covered the entire path from the home screen to the backend inference pipeline, moving beyond visual similarity toward behavioral and functional similarity.
1. The Core Methodology: Why Not Use Reverse Engineering?
Traditional app replication often involves heavyweight techniques such as JADX decompilation, Frida hooks, and traffic interception. This project took a different approach: clean-room replication.
The process treats the target application as a black-box product research subject. There is no need to understand how the original app handles thread scheduling, memory management, or other internal implementation details. The focus is limited to two observable elements:
- Inputs: What the user does on the screen, such as tapping, swiping, or entering text.
- Outputs: How the screen changes, including navigation, control updates, data rendering, and the appearance of generated images or videos.
Based on this principle, the workflow was organized into five stages:
Scope → Probe → Inspect → Spec → Build & Verify
2. The Five-Step Workflow: From Device Connection to Acceptance Testing
2.1 Scope with L0–L5 Levels: Avoid Static Fake Data
A common failure mode in app replication is producing a “high-fidelity presentation prototype”: the interface looks nearly identical, but buttons do nothing. Before implementation begins, the replication target must be defined clearly.
- L0 — Visual skeleton: Static screens or screenshots with no interaction.
- L1 — Static recreation: UI rebuilt from screenshots with local placeholder data.
- L2 — Interaction simulation: Navigation and screen transitions work, but data remains hard-coded.
- L3 — Effect-level consistency: The core user journey is functional and uses real cloud inference APIs. The generated results are consistent with the target application at the algorithmic-effect level. This was the default target for the project.
- L4 — Automated coverage: A UI automation framework is introduced to validate core paths through regression testing.
- L5 — Performance and analytics alignment: Crash rates, frame-rate variations, behavioral data, and business metrics are brought to the same general level as the target application.
For most validation-oriented projects, L3 offers the best balance between functionality, time, and cost.
2.2 Probe with ADB: Direct Control of a Real Device
The main test device was an Android phone with Developer Options and USB debugging enabled. Using Android Debug Bridge (ADB), the device could be controlled directly from a terminal.
No additional hook application was required. Taps were simulated with commands such as:
input tap x y
Swipes were reproduced with:
input swipe x1 y1 x2 y2 duration
This coordinate-driven approach avoided dependence on specific controls in the UI Automator framework and allowed the actual interaction paths to be reproduced more directly.
2.3 Inspect the Semantic Tree and Screenshots: Recover Structure and Visual Details
Inspection was one of the most important stages of the workflow. Instead of relying only on OCR or XML layout analysis, the process used Android’s built-in UI inspection tools.
The following command exports the hierarchy of controls currently displayed on the screen:
uiautomator dump
The resulting semantic tree includes the class name, text content, resource ID, and precise coordinate bounds of interactive elements.
At the same time, the current screen can be captured as a bitmap with:
adb exec-out screencap -p
Comparing the semantic tree with the screenshot makes it possible to extract both structure and visual characteristics, including:
- Color systems, such as primary and secondary accent colors
- Card corner radii and shadow blur values
- Typography, including heading size, body size, font weight, and line height
This dual-analysis process answers two different questions: where each control is located and what it looks like.
2.4 Create a Specification: Turn Visual Impressions into Measurable Differences
Once the screen data has been collected, the next step is to replace subjective judgments with measurable specifications. Two documents are particularly useful.
Screen-by-Screen UI Difference Report
The target screenshot and the recreated screen are compared using image-similarity or pixel-level comparison methods. The report records fine-grained differences, such as:
- The right margin of the search bar on the home screen is off by 4 pixels.
- The RGB value of a card shadow differs by 3%.
Behavior Audit Table
The behavior audit records the state change associated with every user action. For example, after the user taps a “Text-to-Video” or “Image-to-Video” feature:
- The server should create and return a task ID.
- The client should poll that task ID.
- The progress indicator should update.
- The generated result should be rendered when the task is complete.
The audit should cover the full chain, including request initiation, response delivery, UI refresh, and the duration of each stage.
2.5 Rebuild the Native Client and Backend
This stage separates the application’s visible shell from its functional core.
Native Client
The Android interface was written in Kotlin. The component tree was built from the coordinates and control types extracted from the semantic tree. The colors, corner radii, and other visual values identified from screenshots were then used to define shared design tokens through Compose or XML.
Backend
A lightweight backend was built with Python and FastAPI. It connected the client to the underlying large-model APIs.
The backend was not merely an HTTP proxy. It served as a business orchestration layer responsible for:
- Task queue scheduling
- Asynchronous task callbacks
- Persistent storage for multiple versions of generated results
The key validation requirement was that a request such as “extend the video by 16 seconds” had to trigger a real call to an image outpainting model. The model needed to extend the video frames and return a playable MP4 file. Returning a pre-downloaded sample video would not satisfy the requirement.
3. Major Technical Challenges and Mitigation Strategies
Even with a clear workflow, several practical problems emerged.
3.1 Virtualized Loading Problems in Long Lists
When recreating the home-screen feed, placing hundreds of local records directly into the interface could lead to excessive memory usage or dropped frames.
The solution was to follow the native virtualization patterns provided by LazyColumn or RecyclerView. Additional network requests should be triggered only when the user approaches a defined scroll threshold, with adjacent pages loaded progressively.
3.2 Inconsistent Large-Model Output Formats
Inference APIs do not always return clean JSON. Responses may include Markdown syntax, malformed content, or encoding problems.
The server therefore needs defensive parsing. Possible measures include:
- Extracting JSON blocks with regular expressions
- Cleaning malformed or extraneous data
- Validating the result before passing it to the client
This keeps the rendering layer stable even when model output is imperfect.
3.3 Managing the Psychological Impact of End-to-End Latency
If image generation takes 30 seconds, users may assume that the application has frozen. The original product may have similar latency, but the replica still needs to make progress visible.
The implementation can reduce perceived waiting time by optimizing the HTTP connection pool and enabling streaming responses through Server-Sent Events (SSE). The progress indicator should advance smoothly instead of appearing to remain still and then jumping forward.
4. Retrospective: Measuring Time, Cost, and Applicability
- Time: Seven hours in total. Approximately two hours required direct human intervention, while the remaining time was largely spent waiting for model inference.
- API cost: The main expenses came from visual-model analysis of screenshots, performed dozens of times, and image or video generation, also performed dozens of times. The total cost was approximately RMB 21 for the task.
- Applicability: L3 replication is broadly useful for functional validation, but the approach has clear limitations when applied to complex business logic, such as real-time instant messaging or sophisticated animated transitions. More advanced engineering techniques would be required in those cases.
5. Conclusion
Reverse engineering is not the only way to understand and reproduce an application. Combining AI-based analysis with automation creates a more direct and efficient engineering model for app replication.
By turning visual and behavioral observations into structured specifications, developers can rebuild a functional AI product in only a few hours and at relatively low cost. This methodology is useful for rapid prototype validation, product exploration, and testing new application concepts. Its greatest value lies not in producing a static visual copy, but in reconstructing a working interaction and inference pipeline that can be tested on a real device.
