Android Environment API
September 18, 2025 · View on GitHub
This project provides a FastAPI‑based HTTP interface for spinning up and controlling an Android environment (emulator or physical device) to facilitate model testing.
Features
- Launch and manage Android Virtual Devices (AVDs) or connect to physical devices via ADB
- Expose REST endpoints for common operations (screenshot, input events, recording, etc.)
- Lightweight Docker setup for easy deployment
- Native server installation option for full flexibility
Prerequisites
Environment Configuration Options
You can set up your Android environment in either of the following ways (no particular order):
-
Docker‑based Emulator
- Install Docker
# Follow your OS guide: https://docs.docker.com/engine/install/ - Prepare the AVD Docker image
- Based on THUDM/Android-Lab with minor tweaks in our
Dockerfile. - See here for full instructions.
- Based on THUDM/Android-Lab with minor tweaks in our
- (Optional) Customize AVD
- Modify system images or device configs by referencing the THUDM/Android-Lab’s manual.
- Install Docker
-
Local VM or Physical Device
- Install Android SDK & ADB
(See https://developer.android.com/tools) - Option A: Local VM
- Install Android Studio
- Create or download an AVD in AVD Manager → note the AVD name.
- Option B: Physical Device
- Enable Developer Mode & USB Debugging on your device.
- Connect via USB, then verify:
adb devices - Approve the host fingerprint on the device when prompted.
- Install Android SDK & ADB
Running the API Server
Once your Android emulator or device is up and reachable:
cd env_api
uvicorn env_api_launch:app --host 0.0.0.0 --port <PORT>
Replace <PORT> with your chosen port (e.g., 8000).
The interactive API docs will be at http://<SERVER_IP>:<PORT>.
References
- Docker: https://docs.docker.com/engine/install/
- Android‑Lab prep:
docs/prepare_for_linux.md(based on https://github.com/THUDM/Android-Lab) - Android SDK tools: https://developer.android.com/tools
- Android Studio: https://developer.android.com/studio/intro