dotnet/maui · error · Exception
Unexpected platform (expected: android) in device: {deviceDe
Error message
Unexpected platform (expected: android) in device: {deviceDescriptor} What it means
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'.
Source
Thrown at eng/devices/android.cake:392
return settings;
}
void DetermineDeviceCharacteristics(string deviceDescriptor, int defaultApiLevel)
{
var isArm64 = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.Arm64;
var working = deviceDescriptor.Trim().ToLower();
var emulator = true;
var api = defaultApiLevel;
// version
if (working.IndexOf("_") is int idx && idx > 0)
{
api = int.Parse(working.Substring(idx + 1));
working = working.Substring(0, idx);
}
var parts = working.Split('-');
// os
if (parts[0] != "android")
throw new Exception("Unexpected platform (expected: android) in device: " + deviceDescriptor);
// device/emulator
Information("Create for: {0}", parts[1]);
if (parts[1] == "device")
emulator = false;
else if (parts[1] != "emulator" && parts[1] != "simulator")
throw new Exception("Unexpected device type (expected: device|emulator) in device: " + deviceDescriptor);
// arch/bits
Information("Host OS System Arch: {0}", System.Runtime.InteropServices.RuntimeInformation.OSArchitecture);
Information("Host Processor System Arch: {0}", System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture);
if (parts[2] == "32")
{
if (emulator)
deviceArch = "x86";
else
deviceArch = "armeabi-v7a";
}
else if (parts[2] == "64")
{View on GitHub (pinned to f377ff1c5e)
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.
Example fix
# before --device=ios-simulator-64 # after --device=android-emulator-64_30
Defensive patterns
Strategy: validation
Validate before calling
var parts = deviceDescriptor.Trim().ToLower().Split('-');
if (parts.Length < 3 || parts[0] != "android")
throw new Exception($"Invalid device descriptor '{deviceDescriptor}'. Expected format: android-<device|emulator>-<32|64>[_<apiLevel>]"); Type guard
bool IsValidAndroidDescriptor(string d) {
if (string.IsNullOrWhiteSpace(d)) return false;
var p = d.Trim().ToLower().Split('-');
return p.Length >= 3 && p[0] == "android";
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Unexpected device type (expected: device|emulator) in device
- Environment variable 'ANDROID_SDK_ROOT' or 'ANDROID_HOME' mu
- JAVA_HOME environment variable isn't set. Set it to your JDK
- UI Test application path not specified.
- The emulator did not finish booting in time.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/37aeb1d8f1d87996.
Report an issue: GitHub.