{"record":{"id":"83c9d47d8ca383ad","repo":"microsoft/playwright","slug":"no-device-with-serial-number-options-deviceseri","errorCode":null,"errorMessage":"No device with serial number '${options.deviceSerialNumber}' was found","messagePattern":"No device with serial number '(.+?)' was found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/androidServerImpl.ts","lineNumber":44,"sourceCode":"\nexport class AndroidServerLauncherImpl {\n  async launchServer(options: LaunchAndroidServerOptions = {}): Promise<BrowserServer> {\n    const playwright = createPlaywright({ sdkLanguage: 'javascript', isServer: true });\n    // 1. Pre-connect to the device\n    const controller = new ProgressController();\n    let devices = await controller.run(progress => playwright.android.devices(progress, {\n      host: options.adbHost,\n      port: options.adbPort,\n      omitDriverInstall: options.omitDriverInstall,\n    }));\n\n    if (devices.length === 0)\n      throw new Error('No devices found');\n\n    if (options.deviceSerialNumber) {\n      devices = devices.filter(d => d.serial === options.deviceSerialNumber);\n      if (devices.length === 0)\n        throw new Error(`No device with serial number '${options.deviceSerialNumber}' was found`);\n    }\n\n    if (devices.length > 1)\n      throw new Error(`More than one device found. Please specify deviceSerialNumber`);\n\n    const device = devices[0];\n\n    const path = options.wsPath ? (options.wsPath.startsWith('/') ? options.wsPath : `/${options.wsPath}`) : `/${createGuid()}`;\n\n    // 2. Start the server\n    const server = new PlaywrightServer({ mode: 'launchServer', path, maxConnections: 1, preLaunchedAndroidDevice: device });\n    const wsEndpoint = await server.listen(options.port, options.host);\n\n    // 3. Return the BrowserServer interface\n    const browserServer = new EventEmitter() as BrowserServer & EventEmitter;\n    browserServer.wsEndpoint = () => wsEndpoint;\n    browserServer.close = () => device.close(nullProgress);\n    browserServer.kill = () => device.close(nullProgress);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/androidServerImpl.ts#L26-L62","documentation":"Thrown by AndroidServerLauncherImpl.launchServer after filtering devices by `options.deviceSerialNumber` yields zero matches. The supplied serial does not correspond to any currently visible device.","triggerScenarios":"Calling `android.launchServer({ deviceSerialNumber: 'XYZ123' })` where no connected device has `serial === 'XYZ123'`. The filter `devices.filter(d => d.serial === options.deviceSerialNumber)` returns an empty array.","commonSituations":"Wrong serial (typo, stale config); device disconnected before launch; emulator serial mismatch; copied serial from a different machine's adb output.","solutions":["Run `adb devices -l` and copy the exact serial from the first column.","For emulators use the `emulator-<port>` serial form.","Authorize the device (accept the USB debugging prompt) so it appears in the device list."],"exampleFix":"# before\nnode launch-android.js --device-serial-number=XYZ123  # typo\n\n# after\n$ adb devices -l\n# emulator-5554 device\nnode launch-android.js --device-serial-number=emulator-5554","handlingStrategy":"validation","validationCode":"import { execSync } from 'child_process';\nfunction assertSerialKnown(serial: string) {\n  const out = execSync('adb devices', { encoding: 'utf8' });\n  if (!new RegExp(`^${serial}\\\\s+device`, 'm').test(out))\n    throw new Error(`Serial ${serial} not in 'adb devices'; verify with adb devices -l`);\n}","typeGuard":"function isValidSerial(serial: string, adbOutput: string): boolean {\n  return new RegExp(`^${serial}\\\\s+device`, 'm').test(adbOutput);\n}","tryCatchPattern":"try {\n  return await android.launchServer(options);\n} catch (e) {\n  if (/No device with serial number/.test(e.message)) {\n    console.error(`Run 'adb devices -l' and correct --device-serial-number`);\n    process.exit(5);\n  }\n  throw e;\n}","preventionTips":["Source the serial from `adb devices` output rather than hardcoding.","Use `ANDROID_SERIAL` env var consistently across scripts.","Re-run adb discovery after disconnects."],"tags":["android","adb","launch-server","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}