{"record":{"id":"07e77b393411f412","repo":"dotnet/maui","slug":"unexpected-device-type-expected-device-emulator","errorCode":null,"errorMessage":"Unexpected device type (expected: device|emulator) in device: {deviceDescriptor}","messagePattern":"Unexpected device type \\(expected: device\\|emulator\\) in device: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/android.cake","lineNumber":398,"sourceCode":"\tvar working = deviceDescriptor.Trim().ToLower();\n\tvar emulator = true;\n\tvar api = defaultApiLevel;\n\t// version\n\tif (working.IndexOf(\"_\") is int idx && idx > 0)\n\t{\n\t\tapi = int.Parse(working.Substring(idx + 1));\n\t\tworking = working.Substring(0, idx);\n\t}\n\tvar parts = working.Split('-');\n\t// os\n\tif (parts[0] != \"android\")\n\t\tthrow new Exception(\"Unexpected platform (expected: android) in device: \" + deviceDescriptor);\n\t// device/emulator\n\tInformation(\"Create for: {0}\", parts[1]);\n\tif (parts[1] == \"device\")\n\t\temulator = false;\n\telse if (parts[1] != \"emulator\" && parts[1] != \"simulator\")\n\t\tthrow new Exception(\"Unexpected device type (expected: device|emulator) in device: \" + deviceDescriptor);\n\t// arch/bits\n\tInformation(\"Host OS System Arch: {0}\", System.Runtime.InteropServices.RuntimeInformation.OSArchitecture);\n\tInformation(\"Host Processor System Arch: {0}\", System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture);\n\tif (parts[2] == \"32\")\n\t{\n\t\tif (emulator)\n\t\t\tdeviceArch = \"x86\";\n\t\telse\n\t\t\tdeviceArch = \"armeabi-v7a\";\n\t}\n\telse if (parts[2] == \"64\")\n\t{\n\t\tif (isArm64)\n\t\t\tdeviceArch = \"arm64-v8a\";\n\t\telse if (emulator)\n\t\t\tdeviceArch = \"x86_64\";\n\t\telse\n\t\t\tdeviceArch = \"arm64-v8a\";","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/android.cake#L380-L416","documentation":"Thrown while parsing a device descriptor when the second segment (device type) is not one of 'device', 'emulator', or 'simulator'. After confirming the platform is android, the parser expects a concrete device-kind token.","triggerScenarios":"parts[1] is something other than 'device', 'emulator', or 'simulator' — e.g. 'android-phone-64' or 'android-real-64'. (Note 'simulator' is accepted but semantically unusual for Android.)","commonSituations":"Typo in the device type token (phone, real, phys instead of device); copying a descriptor format from another system; an outdated descriptor after the format changed.","solutions":["Use 'device' for a physical Android device or 'emulator' for an Android emulator in the descriptor.","Correct typos in the ANDROID_TEST_DEVICE env var / --device argument.","Refer to the parser's accepted tokens: device | emulator (simulator also accepted)."],"exampleFix":"# before\n--device=android-phone-64_30\n# after\n--device=android-device-64_30","handlingStrategy":"validation","validationCode":"var validTypes = new[] { \"device\", \"emulator\", \"simulator\" };\nif (!validTypes.Contains(parts[1]))\n    throw new Exception($\"Invalid device type '{parts[1]}'. Expected one of: {string.Join(\"|\", validTypes)}.\");","typeGuard":"bool IsValidDeviceType(string descriptor) {\n    var p = descriptor.Trim().ToLower().Split('-');\n    return p.Length >= 2 && new[]{\"device\",\"emulator\",\"simulator\"}.Contains(p[1]);\n}","tryCatchPattern":null,"preventionTips":["List accepted tokens in the error message itself.","Validate the whole descriptor up front rather than failing mid-parse.","Add a unit-style test over the descriptor parser for each accepted shape."],"tags":["android","device-descriptor","validation","config"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}