stablyai/orca · error · EmulatorError

emulator_device_not_found

emulator_device_not_found

Error message

Android device "${deviceOrName}" is not running. Boot it first.

What it means

Thrown by AndroidEmulatorBackend.resolveDeviceId when the requested deviceOrName is neither a running adb serial nor the name of a currently-running AVD. Unlike bootAndroidDevice (error 1003), resolveDeviceId does NOT attempt to boot a new emulator — it only resolves among already-running devices. The message explicitly directs the caller to boot the device first.

Source

Thrown at src/main/emulator/backends/android-emulator-backend.ts:163

  async ownsDevice(id: string): Promise<boolean> {
    if (!this.sdkState.resolve()) {
      return false
    }
    const devices = await this.listDevices()
    return devices.some((device) => device.id === id || device.name === id)
  }

  async resolveDeviceId(deviceOrName: string): Promise<string> {
    const sdk = this.requireSdk()
    const running = await listRunningAdbDevices(this.runner, sdk)
    if (running.some((device) => device.serial === deviceOrName)) {
      return deviceOrName
    }
    const serial = await findRunningAvdSerial(this.runner, sdk, deviceOrName, running)
    if (serial) {
      return serial
    }
    throw new EmulatorError(
      'emulator_device_not_found',
      `Android device "${deviceOrName}" is not running. Boot it first.`
    )
  }

  async startSession(deviceId: string): Promise<EmulatorSessionInfo> {
    return this.streams.start(await this.ensureBooted(deviceId))
  }

  async stopHelperForDevice(
    deviceId: string,
    options: { helperPid?: number; includeOrphaned?: boolean } = {}
  ): Promise<void> {
    this.streams.stop(deviceId)
    // Reap a port-forward leaked by an unclean exit: the in-memory handle is gone
    // after a crash, so streams.stop can't remove it. Best-effort, serial-scoped,
    // and must never throw on this teardown path.
    if (options.includeOrphaned) {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Boot the device first via the boot path (bootAndroidDevice or ensureBooted) before calling resolveDeviceId-dependent operations.
  2. Verify with `adb devices` that the target serial shows 'device' status.
  3. If the emulator died, restart it and re-resolve.
  4. Pass a running serial rather than an AVD name to read-only operations.

Example fix

// before: resolve against a cold device
const id = await backend.resolveDeviceId('Pixel_API_34')
await backend.type(id, 'hello')
// after: boot first, then resolve
await bootAndroidDevice(runner, sdk, 'Pixel_API_34', bootOpts)
const id = await backend.resolveDeviceId('Pixel_API_34')
await backend.type(id, 'hello')
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the device is running before calling resolve-only operations.
async function isDeviceRunning(runner, sdk, name: string): Promise<boolean> {
  const running = await listRunningAdbDevices(runner, sdk)
  return running.some(d => d.serial === name) || !!(await findRunningAvdSerial(runner, sdk, name, running))
}

Type guard

import { EmulatorError } from '../emulator-errors'
function isDeviceNotRunning(e: unknown): e is EmulatorError {
  return e instanceof EmulatorError && e.code === 'emulator_device_not_found'
}

Try / catch

try { return await backend.resolveDeviceId(name) }
catch (e) {
  if (isDeviceNotRunning(e)) {
    await bootAndroidDevice(runner, sdk, name, bootOpts) // boot then re-resolve
    return await backend.resolveDeviceId(name)
  }
  throw e
}

Prevention

When it happens

Trigger: resolveDeviceId(deviceOrName) where listRunningAdbDevices contains no matching serial AND findRunningAvdSerial returns null. This path is used by startSession, gesture, type, button, etc. — operations that require an already-booted device and will not auto-launch one.

Common situations: Calling any device-targeted operation before the emulator is booted; an emulator that crashed between resolution and use; passing an AVD name instead of a running serial to a non-boot API; a serial that timed out and dropped off adb devices.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/d894f788542eb285. Report an issue: GitHub.