start_emulator
Start an Android emulator and wait for it to come online. Specify the AVD name to launch the virtual device for testing and development.
Instructions
Start an Android emulator. Waits up to 60s for it to come online.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| avd_name | Yes | Name of the AVD to start (from list_avds) |
Implementation Reference
- src/adb.ts:202-226 (handler)The `startEmulator` method in the `Adb` class handles launching the emulator and polling until the device appears online.
async startEmulator(avdName: string): Promise<string> { const beforeDevices = await this.getDevices(); const beforeIds = new Set(beforeDevices.map((d) => d.id)); const child = spawn(this.emulatorPath, ["-avd", avdName], { detached: true, stdio: "ignore", }); child.unref(); const maxWaitMs = 60_000; const pollIntervalMs = 2_000; const start = Date.now(); while (Date.now() - start < maxWaitMs) { await new Promise((r) => setTimeout(r, pollIntervalMs)); const currentDevices = await this.getDevices(); const newDevice = currentDevices.find( (d) => !beforeIds.has(d.id) && d.state === "device", ); if (newDevice) return newDevice.id; } throw new Error(`Emulator "${avdName}" did not come online within ${maxWaitMs / 1000}s`); }