{"record":{"id":"f5e592fbd3358648","repo":"Unity-Technologies/UnityCsReference","slug":"couldn-t-create-device-api-for-device-deviceid","errorCode":null,"errorMessage":"Couldn't create device API for device: {deviceId}","messagePattern":"Couldn't create device API for device: (.+?)","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Modules/ModuleManager.cs","lineNumber":285,"sourceCode":"            if (platformSupportModulesByGuid.TryGetValue(platformGuid, out var module))\n                return module;\n\n            return null;\n        }\n\n        internal static IDevice GetDevice(string deviceId)\n        {\n            DevDevice device;\n            if (DevDeviceList.FindDevice(deviceId, out device))\n            {\n                IPlatformSupportModule module = FindPlatformSupportModule(device.module);\n                if (module != null)\n                    return module.CreateDevice(deviceId);\n                else\n                    throw new ApplicationException(\"Couldn't find module for target: \" + device.module);\n            }\n\n            throw new ApplicationException(\"Couldn't create device API for device: \" + deviceId);\n        }\n\n        internal static IBuildTarget GetIBuildTarget(BuildTarget target)\n        {\n            var targetModuleName = BuildTargetDiscovery.GetModuleNameForBuildTarget(target);\n            if (platformSupportModules.TryGetValue(targetModuleName, out var module))\n            {\n                return module.PlatformBuildTarget;\n            }\n\n            return null;\n        }\n\n        internal static IBuildTarget GetIBuildTarget(GUID platformGuid)\n        {\n            if (platformSupportModulesByGuid.TryGetValue(platformGuid, out var module))\n            {\n                if (module.PlatformBuildTarget.Guid == platformGuid)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Modules/ModuleManager.cs#L267-L303","documentation":"Thrown by ModuleManager.GetDevice when DevDeviceList.FindDevice returns false — no device with the given deviceId is registered in the device list at all. This is the outer guard, distinct from 402 which fires when the device exists but its module is missing.","triggerScenarios":"Calling ModuleManager.GetDevice(deviceId) with an ID that does not match any entry in DevDeviceList (e.g., disconnected device, stale ID from a previous session, typo).","commonSituations":"Device disconnected between discovery and use. DeviceId read from a saved editor state that no longer resolves. Device driver not installed so FindDevice never populates the list.","solutions":["Verify the device is connected and recognized: refresh the device list (DevDeviceList) before calling GetDevice.","Check the deviceId string for typos or trailing whitespace.","Install/enable the device's USB driver or network discovery provider.","Wrap the call and fall back to a re-scan: if FindDevice fails, re-enumerate then retry once."],"exampleFix":"// before\nIDevice d = ModuleManager.GetDevice(deviceId); // throws if device gone\n// after\nDevDevice device;\nif (DevDeviceList.FindDevice(deviceId, out device))\n    IDevice d = ModuleManager.GetDevice(deviceId);\nelse\n    RefreshDeviceList();","handlingStrategy":"validation","validationCode":"DevDevice dev;\nif (DevDeviceList.FindDevice(deviceId, out dev))\n    IDevice d = ModuleManager.GetDevice(deviceId);","typeGuard":null,"tryCatchPattern":"try { var d = ModuleManager.GetDevice(id); }\ncatch (ApplicationException ex) when (ex.Message.Contains(\"create device\"))\n{ /* device gone — re-enumerate */ }","preventionTips":["Re-enumerate the device list before use.","Validate deviceId strings for whitespace.","Handle device disconnect between discovery and use."],"tags":["unity","modules","device","not-found"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}