{
  "id": "dotnet/maui-platform-not-supported-android",
  "signature": "System.PlatformNotSupportedException: Operation is not supported on this platform. (Android)",
  "signature_zh": "System.PlatformNotSupportedException: 此平台不支持该操作。(Android)",
  "regex": "System\\.PlatformNotSupportedException: Operation is not supported on this platform\\. \\(Android\\)",
  "domain": "dotnet",
  "category": "platform_error",
  "subcategory": null,
  "root_cause": "A .NET MAUI or Xamarin.Forms app is calling an API that is not available on the Android platform, such as Windows-specific filesystem APIs or iOS-only frameworks, without proper platform checks.",
  "root_cause_type": "generic",
  "root_cause_zh": ".NET MAUI 或 Xamarin.Forms 应用程序调用了 Android 平台不可用的 API，例如 Windows 特定的文件系统 API 或 iOS 专属框架，而没有进行适当的平台检查。",
  "versions": [
    {
      "version": ".NET MAUI 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET MAUI 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET MAUI 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Xamarin.Android 12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Xamarin.Android 13.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding a try-catch around the call and ignoring the exception.",
      "why_fails": "This suppresses the error but does not provide the intended functionality; it may lead to silent data loss or incorrect behavior.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using conditional compilation (#if ANDROID) without implementing an alternative for Android.",
      "why_fails": "If the alternative is not implemented, the code will not execute at all, leaving functionality missing.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Downgrading the target framework to an older version that supports the API.",
      "why_fails": "The API is platform-specific; downgrading does not change the underlying OS capabilities.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use conditional compilation with platform-specific implementations. Example: #if ANDROID // Android-specific code using Android.Content.Intent #elif IOS // iOS-specific code using UIKit.UIApplication #endif",
      "success_rate": 0.85,
      "how": "Use conditional compilation with platform-specific implementations. Example: #if ANDROID // Android-specific code using Android.Content.Intent #elif IOS // iOS-specific code using UIKit.UIApplication #endif",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the DeviceInfo.Platform property from Xamarin.Essentials or MAUI Essentials to check at runtime: if (DeviceInfo.Platform == DevicePlatform.Android) { /* Android code */ } else { /* fallback */ }",
      "success_rate": 0.9,
      "how": "Use the DeviceInfo.Platform property from Xamarin.Essentials or MAUI Essentials to check at runtime: if (DeviceInfo.Platform == DevicePlatform.Android) { /* Android code */ } else { /* fallback */ }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use dependency injection with platform-specific services. Register an interface in the shared project and implement it in each platform project. Example: services.AddSingleton<IFileService, AndroidFileService>();",
      "success_rate": 0.95,
      "how": "Use dependency injection with platform-specific services. Register an interface in the shared project and implement it in each platform project. Example: services.AddSingleton<IFileService, AndroidFileService>();",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use conditional compilation with platform-specific implementations. Example: #if ANDROID // Android-specific code using Android.Content.Intent #elif IOS // iOS-specific code using UIKit.UIApplication #endif",
    "Use the DeviceInfo.Platform property from Xamarin.Essentials or MAUI Essentials to check at runtime: if (DeviceInfo.Platform == DevicePlatform.Android) { /* Android code */ } else { /* fallback */ }",
    "Use dependency injection with platform-specific services. Register an interface in the shared project and implement it in each platform project. Example: services.AddSingleton<IFileService, AndroidFileService>();"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-05-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}