Skip to content

Android emulator: crashes & screen-recording tools fail with "device not found" (adb id vs mobilecli AVD-name id); start_screen_recording silently false-succeeds #359

Description

@TonyDowney

Summary

On an Android emulator, four tools — mobile_list_crashes, mobile_get_crash, mobile_start_screen_recording, mobile_stop_screen_recording — fail because mobile-mcp passes the adb device id to the bundled mobilecli, but mobilecli identifies the same emulator by its AVD name. The adb-based tools (screenshot, tap, elements, etc.) all work; only the mobilecli-backed tools break. Worse, mobile_start_screen_recording returns success but records nothing (silent failure).

Environment

mobile-mcp 0.0.59
bundled mobilecli 0.3.79
Device Pixel 7 API 33 emulator, Android 13
adb 1.0.41
Host macOS 26.5.1 (arm64), Node v25.9.0

Root cause: device-id mismatch between the adb path and the mobilecli path

mobile_list_available_devices returns the Android emulator with the adb id:

{ "id": "emulator-5554", "platform": "android", "type": "emulator", ... }

…but mobilecli knows the very same emulator by its AVD name:

$ mobilecli devices --platform android
{ "data": { "devices": [ { "id": "Pixel_7_API_33", "platform": "android", "type": "emulator", "model": "sdk_gphone64_arm64" } ] } }

So when a mobilecli-backed tool forwards the id the user got from list_available_devices, it fails:

$ mobilecli device crashes list --device emulator-5554
{ "status": "error", "error": "error finding device: device not found: emulator-5554" }

$ mobilecli device crashes list --device Pixel_7_API_33      # AVD name works
{ "status": "ok", "data": [ { "processName": "com.android.chrome:privileged_process0", ... } ] }

In lib/server.js, the adb-based Android tools come from AndroidRobot (adb ids), while these route to mobilecli:

  • mobile_list_crashesmobilecli.crashesList(device)
  • mobile_get_crashmobilecli.crashesGet(device, id)
  • mobile_start_screen_recordingmobilecli.spawnCommand(["screenrecord", "--device", device, "--output", outputPath, "--silent"])

lib/android.js has no screenrecord implementation, so recording has no adb fallback. There is no single id that works across all tools: adb-based tools require emulator-5554, mobilecli-based tools require Pixel_7_API_33.

Extra bug: start_screen_recording silently false-succeeds

spawnCommand launches the mobilecli screenrecord child, which immediately exits with the device not found error. But the handler still returns "Screen recording started…" and registers the recording; the child's error/exit handler then activeRecordings.delete(device). Result:

start_screen_recording  -> "Screen recording started. Output will be saved to: /tmp/android_rec.mp4"   (but no child is running)
stop_screen_recording   -> "No active recording found for device emulator-5554..."                      (entry already deleted)

No screenrecord process ever ran on the device and no file is produced — yet start reported success.

Reproduction

  1. Boot an Android emulator; mobile_list_available_devices → note the emulator-5554 id.
  2. mobile_list_crashes({device: "emulator-5554"})device not found: emulator-5554.
  3. mobile_start_screen_recording({device: "emulator-5554", output: "/tmp/r.mp4"}) → returns "started".
  4. mobile_stop_screen_recording({device: "emulator-5554"}) → "No active recording found"; /tmp/r.mp4 does not exist.

Suggested fix

  • Reconcile the device id before calling mobilecli for Android — map the adb id (emulator-5554) to the mobilecli/AVD id (Pixel_7_API_33), or have list_available_devices expose a single id that every code path accepts.
  • Don't let start_screen_recording report success when the child fails to start — await/verify the mobilecli child is alive (and the device resolved) before returning, and surface the error.

Happy to test a patch — repro is consistent here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions