{"record":{"id":"37aeb1d8f1d87996","repo":"dotnet/maui","slug":"unexpected-platform-expected-android-in-device","errorCode":null,"errorMessage":"Unexpected platform (expected: android) in device: {deviceDescriptor}","messagePattern":"Unexpected platform \\(expected: android\\) in device: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/android.cake","lineNumber":392,"sourceCode":"\treturn settings;\n}\n\nvoid DetermineDeviceCharacteristics(string deviceDescriptor, int defaultApiLevel)\n{\n\tvar isArm64 = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.Arm64;\n\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{","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/android.cake#L374-L410","documentation":"Thrown while parsing a device descriptor string when the first hyphen-delimited segment is not 'android'. The descriptor format is '<platform>-<deviceType>-<bits>[_<apiLevel>]' (e.g. android-emulator-64_30), and the platform token must be exactly 'android'.","triggerScenarios":"A device descriptor whose lowercased first segment (parts[0]) is not 'android' — e.g. 'ios-simulator-64', 'win-device-x64', or a typo like 'androi-emulator-64'.","commonSituations":"Passing a device string formatted for a different platform (iOS/Catalyst/Windows) into the Android device helper; a typo in the device name; a CI matrix variable injecting the wrong platform descriptor.","solutions":["Use a descriptor starting with 'android-', e.g. android-emulator-64_30 or android-device-64.","Check the ANDROID_TEST_DEVICE env var / --device argument for typos or wrong-platform values.","Ensure the CI matrix job that targets Android passes Android-formatted descriptors only."],"exampleFix":"# before\n--device=ios-simulator-64\n# after\n--device=android-emulator-64_30","handlingStrategy":"validation","validationCode":"var parts = deviceDescriptor.Trim().ToLower().Split('-');\nif (parts.Length < 3 || parts[0] != \"android\")\n    throw new Exception($\"Invalid device descriptor '{deviceDescriptor}'. Expected format: android-<device|emulator>-<32|64>[_<apiLevel>]\");","typeGuard":"bool IsValidAndroidDescriptor(string d) {\n    if (string.IsNullOrWhiteSpace(d)) return false;\n    var p = d.Trim().ToLower().Split('-');\n    return p.Length >= 3 && p[0] == \"android\";\n}","tryCatchPattern":null,"preventionTips":["Document the exact descriptor format where the device argument is defined.","Validate descriptors at the start of the script and fail with the expected format.","Keep platform-specific descriptors out of shared CI matrix variables."],"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"}