Unified script that installs prerequisites and manages the emulator API service lifecycle on Windows and macOS hosts.
| Requirement | Details |
|---|---|
| OS | Windows x86_64 or ARM64 (run via Git Bash / MSYS2) |
| PowerShell | powershell.exe or pwsh must be on PATH |
| MuMu Player | Auto-installed via winget when available, otherwise via the official MuMu installer; custom MUMU_MANAGER_PATH is also supported |
| Bundled ADB | adb.exe sibling to MuMuManager.exe (ships with MuMu Player) |
| Python | 3.13+ (.venv, py -3, python3, or python) |
| Requirement | Details |
|---|---|
| OS | macOS Apple Silicon or Intel x86_64 |
| Android SDK | ANDROID_HOME or default ~/Library/Android/sdk |
| Required tools | platform-tools/adb, emulator/emulator, cmdline-tools/latest/bin/avdmanager |
| Python | 3.13+ (.venv, python3, or python) |
WSL / Linux are not supported. The script exits with a clear error on unsupported platforms.
From the repository root:
# Full install + start API service
make emulator-setup
# Bootstrap the default emulator device
make emulator-bootstrapFrom this directory:
# Full install + start API service
./setup.sh
# Bootstrap the default emulator device
./setup.sh bootstrap
# One-step install + start + bootstrap, useful for fresh setup
./setup.sh install --bootstrap
# Install only, don't start
./setup.sh install --no-start
# Stop emulator devices explicitly
./setup.sh stop-devices
# Start / stop / restart / status the API service only
./setup.sh start
./setup.sh stop
./setup.sh restart
./setup.sh status
# Tail logs
./setup.sh logs
# Start in foreground (Ctrl+C to stop)
./setup.sh start --foreground| Command | Description |
|---|---|
install |
Install all prerequisites and start the API service by default |
start |
Start the emulator API service in background; does not start emulator devices |
stop |
Stop the API service; does not stop emulator devices |
restart |
Restart the API service only |
status |
Show whether the API service is running |
bootstrap |
Bootstrap the default emulator device and install cached APKs; requires the API service to be running |
stop-devices |
Stop all running emulator devices explicitly |
logs |
Tail the service log file |
help |
Show built-in help |
| Flag | Description |
|---|---|
--skip-mumu |
Skip MuMu Player download/install |
--skip-sdk |
Skip Android SDK installation on macOS |
--skip-adbkeyboard |
Skip ADBKeyboard APK installation |
--skip-edge |
Skip Microsoft Edge APK installation |
--skip-virtualization |
Skip Hyper-V / virtualization enablement |
--skip-deps |
Skip Python dependency installation |
--no-start |
Don't start the service after install |
--bootstrap |
After install, start, or restart, run the default device bootstrap |
--foreground |
Start service in foreground instead of background |
--skip-adbis no longer accepted and will cause a fatal error. Bundled ADB verification is mandatory.
| Flag | Default | Description |
|---|---|---|
--host <addr> |
0.0.0.0 |
Bind address |
--port <int> |
8000 |
Bind port (1–65535) |
| Flag | Default | Description |
|---|---|---|
--width <int> |
720 |
Emulator screen width |
--height <int> |
1280 |
Emulator screen height |
--dpi <int> |
320 |
Emulator screen DPI |
The script resolves the MuMu management tool in this order:
MUMU_MANAGER_PATHenvironment variableMUMU_MANAGER_PATH=insandbox/emulator/.env- Auto-detected installed path from Windows uninstall metadata, running MuMu processes, or common install locations
- Default path:
C:\Program Files\Netease\MuMu\nx_main\MuMuManager.exe
If the configured path doesn't exist, the script first tries to auto-detect the real MuMu installation path before falling back to the default location. This allows a manual non-default installation to be picked up on the next ./setup.sh run without editing .env.
Bundled ADB is automatically resolved on Windows:
- Windows:
adb.exein the same directory asMuMuManager.exe
The script resolves ANDROID_HOME in this order:
ANDROID_HOMEenvironment variableANDROID_HOME=insandbox/emulator/.env- Default path:
~/Library/Android/sdk
ADB is expected at platform-tools/adb, the emulator binary at emulator/emulator, and avdmanager at cmdline-tools/latest/bin/avdmanager.
- Hyper-V & Virtualization: enables Windows features (requires admin; skippable)
- MuMu Player: checks existence, tries non-interactive
wingetinstall first, then falls back to the official MuMu installer; downloaded installers must pass Authenticode signature verification before execution; if silent install does not work, setup waits for the installer window to finish and continues automatically afterMuMuManager.exeis detected; fatal if still missing - Bundled ADB: validates
adb.exenext toMuMuManager.exe; fatal if missing - Python dependencies: auto-creates or repairs
sandbox/emulator/.venvwhen needed, bootstrapspipwithensurepip, then runspip install -e .frompyproject.toml; fatal if packaging tooling is still unavailable - Download APKs: pre-downloads ADBKeyboard and Microsoft Edge APKs (optional)
After installation, if MuMu was installed during the current run, setup best-effort stops the installer-started reserved pad instance at device-0 before the service starts. Normal service lifecycle commands do not create, start, or stop MuMu devices. After the API service is running, run ./setup.sh bootstrap (or use ./setup.sh install --bootstrap) when you want the script to reuse an existing non-zero MuMu device, create one if needed, start it, apply display defaults, and install cached APKs via the API.
The macOS flow bootstraps Java if needed, then runs these numbered steps:
- Android SDK command-line tools: installs
sdkmanager/avdmanager - SDK packages: installs
platform-tools,emulator, and the Android 35 system image - ADB validation: verifies
platform-tools/adb - AVD creation: creates
${AVD_NAME_PREFIX}0when missing - Python dependencies: installs the FastAPI service package
- Display configuration: writes the default screen size and DPI into the AVD config
- ADBKeyboard + Edge: downloads APKs during setup. After the API service is running, run
./setup.sh bootstrap(or use./setup.sh install --bootstrap) to start the default AVD and install them via the API.
start and restart validate the runtime backend before launching the API service. If the Android SDK is incomplete on macOS, startup fails early instead of advertising a healthy API.
Device operations are intentionally explicit. This avoids surprising open-source users by opening, creating, or closing GUI emulator instances when they only asked to manage the API daemon.
./setup.sh bootstraprequires the API service to be running, then starts/creates the default emulator device and installs cached APKs.- On Windows, bootstrap skips the reserved MuMu device-0 index, reuses an existing non-zero device when possible, and creates one phone-mode device only when needed.
- On macOS, bootstrap creates
device0if missing, then starts it. ./setup.sh stop-devicesstops all running emulator devices explicitly../setup.sh stoponly stops the API service.
- Background mode: launches via
nohup, writes PID to.emulator-service.pidand state to.emulator-service.env, and polls/healthfor readiness (20 attempts). If readiness fails, the orphan process is automatically terminated. - Foreground mode: uses
execto replace the shell process. Ctrl+C to stop. - State files:
.emulator-service.pidand.emulator-service.envtrack PID, host, and port forstop/status/restart. - Process matching: validates PID via
pscmdline orlsofport check to avoid acting on stale PIDs. - Graceful shutdown:
stopsends SIGTERM to the API service, waits 10s, and sends SIGKILL if the process is still alive. It does not stop emulator devices; usestop-devicesfor that. - Health semantics:
/healthreturns503when the emulator backend is not ready, so setup and orchestration do not treat a broken backend as healthy.
The script finds Python 3.13+ in this order:
sandbox/emulator/.venv/bin/pythonor.venv/Scripts/python.exepy -3(Windows Python Launcher)python3python
A PYTHON_CMD array is built once and reused for all Python operations (eval, pip, uvicorn).
During install, if no usable local .venv interpreter exists, the script creates or repairs sandbox/emulator/.venv with the selected 3.13+ base interpreter and then installs dependencies into that local environment.