{"record":{"id":"8038d9fa3c3d1139","repo":"apache/cordova-android","slug":"no-emulator-id-given","errorCode":null,"errorMessage":"No emulator ID given","messagePattern":"No emulator ID given","errorType":"validation","errorClass":"CordovaError","httpStatus":null,"severity":"error","filePath":"lib/emulator.js","lineNumber":202,"sourceCode":"        }\n        throw new CordovaError('Could not find an available avd port');\n    });\n};\n\n/*\n * Starts an emulator with the given ID,\n * and returns the started ID of that emulator.\n * If no boot timeout is given or the value is negative it will wait forever for\n * the emulator to boot\n *\n * Returns a promise.\n */\nmodule.exports.start = function (emulatorId, boot_timeout) {\n    const self = this;\n\n    return Promise.resolve().then(function () {\n        if (!emulatorId) {\n            throw new CordovaError('No emulator ID given');\n        }\n\n        return self.get_available_port().then(function (port) {\n            // Figure out the directory the emulator binary runs in, and set the cwd to that directory.\n            // Workaround for https://code.google.com/p/android/issues/detail?id=235461\n            const emulator_dir = path.dirname(which.sync('emulator'));\n            const args = ['-avd', emulatorId, '-port', port];\n            // Don't wait for it to finish, since the emulator will probably keep running for a long time.\n            execa('emulator', args, { stdio: 'inherit', detached: true, cwd: emulator_dir })\n                .unref();\n\n            // wait for emulator to start\n            events.emit('log', 'Waiting for emulator to start...');\n            return self.wait_for_emulator(port);\n        });\n    }).then(function (emulatorId) {\n        if (!emulatorId) { return Promise.reject(new CordovaError('Failed to start emulator')); }\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/lib/emulator.js#L184-L220","documentation":"emulator.start(emulatorId, boot_timeout) validates its first argument in the initial promise step and throws immediately when emulatorId is falsy. No default-AVD lookup or image resolution happens inside start() - the caller (the run/emulate flow) is expected to pick an existing AVD first.","triggerScenarios":"Direct call emulator.start() / emulator.start(undefined), or `cordova emulate android` when the flow above it found no AVD image to pass (e.g. --target given as empty, or no AVDs exist on the machine).","commonSituations":"Fresh machine or CI image where no AVD has been created (`emulator -list-avds` empty); `cordova emulate android --target=` with an empty value; tooling assuming a default emulator exists.","solutions":["List available AVDs: `emulator -list-avds` or `avdmanager list avd`.","Create one: `avdmanager create avd -n test -k \"system-images;android-34;google_apis;x86_64\"` (install the system image first via sdkmanager).","Run again, optionally pinning it: `cordova emulate android --target=test`."],"exampleFix":"# before\n$ cordova emulate android   # no AVD on the machine\nNo emulator ID given\n\n# after\n$ sdkmanager \"system-images;android-34;google_apis;x86_64\"\n$ avdmanager create avd -n test -k \"system-images;android-34;google_apis;x86_64\"\n$ cordova emulate android --target=test","handlingStrategy":"validation","validationCode":"if (!emulatorId) {\n  throw new Error('No emulator ID given - list with `emulator -list-avds` and pass --target');\n}\nconst avds = (await execa('emulator', ['-list-avds'])).stdout.split(/\\r?\\n/).filter(Boolean);\nif (!avds.includes(emulatorId)) {\n  throw new Error(`AVD '${emulatorId}' not found; available: ${avds.join(', ')}`);\n}","typeGuard":"const isNonEmptyEmulatorId = (id) => typeof id === 'string' && id.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Create the AVD as an explicit CI provisioning step before any emulate command.","Pin `cordova emulate android --target=<avd-name>` instead of relying on a default.","Keep a repository script that lists/creates the expected AVDs on new machines."],"tags":["emulator","avd","missing-argument","cordova-emulate"],"backgroundTag":"missing-required-argument","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}