{"record":{"id":"d894f788542eb285","repo":"stablyai/orca","slug":"emulator-device-not-found-d894f7","errorCode":"emulator_device_not_found","errorMessage":"Android device \"${deviceOrName}\" is not running. Boot it first.","messagePattern":"Android device \"(.+?)\" is not running\\. Boot it first\\.","errorType":"exception","errorClass":"EmulatorError","httpStatus":null,"severity":"error","filePath":"src/main/emulator/backends/android-emulator-backend.ts","lineNumber":163,"sourceCode":"  async ownsDevice(id: string): Promise<boolean> {\n    if (!this.sdkState.resolve()) {\n      return false\n    }\n    const devices = await this.listDevices()\n    return devices.some((device) => device.id === id || device.name === id)\n  }\n\n  async resolveDeviceId(deviceOrName: string): Promise<string> {\n    const sdk = this.requireSdk()\n    const running = await listRunningAdbDevices(this.runner, sdk)\n    if (running.some((device) => device.serial === deviceOrName)) {\n      return deviceOrName\n    }\n    const serial = await findRunningAvdSerial(this.runner, sdk, deviceOrName, running)\n    if (serial) {\n      return serial\n    }\n    throw new EmulatorError(\n      'emulator_device_not_found',\n      `Android device \"${deviceOrName}\" is not running. Boot it first.`\n    )\n  }\n\n  async startSession(deviceId: string): Promise<EmulatorSessionInfo> {\n    return this.streams.start(await this.ensureBooted(deviceId))\n  }\n\n  async stopHelperForDevice(\n    deviceId: string,\n    options: { helperPid?: number; includeOrphaned?: boolean } = {}\n  ): Promise<void> {\n    this.streams.stop(deviceId)\n    // Reap a port-forward leaked by an unclean exit: the in-memory handle is gone\n    // after a crash, so streams.stop can't remove it. Best-effort, serial-scoped,\n    // and must never throw on this teardown path.\n    if (options.includeOrphaned) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/emulator/backends/android-emulator-backend.ts#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Boot the device first via the boot path (bootAndroidDevice or ensureBooted) before calling resolveDeviceId-dependent operations.","Verify with `adb devices` that the target serial shows 'device' status.","If the emulator died, restart it and re-resolve.","Pass a running serial rather than an AVD name to read-only operations."],"exampleFix":"// before: resolve against a cold device\nconst id = await backend.resolveDeviceId('Pixel_API_34')\nawait backend.type(id, 'hello')\n// after: boot first, then resolve\nawait bootAndroidDevice(runner, sdk, 'Pixel_API_34', bootOpts)\nconst id = await backend.resolveDeviceId('Pixel_API_34')\nawait backend.type(id, 'hello')","handlingStrategy":"validation","validationCode":"// Confirm the device is running before calling resolve-only operations.\nasync function isDeviceRunning(runner, sdk, name: string): Promise<boolean> {\n  const running = await listRunningAdbDevices(runner, sdk)\n  return running.some(d => d.serial === name) || !!(await findRunningAvdSerial(runner, sdk, name, running))\n}","typeGuard":"import { EmulatorError } from '../emulator-errors'\nfunction isDeviceNotRunning(e: unknown): e is EmulatorError {\n  return e instanceof EmulatorError && e.code === 'emulator_device_not_found'\n}","tryCatchPattern":"try { return await backend.resolveDeviceId(name) }\ncatch (e) {\n  if (isDeviceNotRunning(e)) {\n    await bootAndroidDevice(runner, sdk, name, bootOpts) // boot then re-resolve\n    return await backend.resolveDeviceId(name)\n  }\n  throw e\n}","preventionTips":["Boot the device via bootAndroidDevice/ensureBooted before resolve-dependent operations.","Verify `adb devices` shows the serial as 'device' before use.","Pass a running serial rather than an AVD name to read-only APIs."],"tags":["android","device-not-found","emulator","lifecycle"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}