{
  "id": "android/notification-channel-missing",
  "signature": "NotificationManager: notification not shown, missing channel. Channel 'my_channel_id' was not created.",
  "signature_zh": "NotificationManager：通知未显示，缺少频道。频道 'my_channel_id' 未创建。",
  "regex": "NotificationManager: notification not shown.*missing channel.*Channel '.*' was not created",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Notification channel not created before posting a notification on Android 8.0+ (API 26+), where channels are mandatory.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Android 8.0+（API 26+）上发布通知前未创建通知频道，而频道是强制性的。",
  "versions": [
    {
      "version": "Android 8.0 (API 26)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 9 (API 28)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 10 (API 29)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 11 (API 30)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 12 (API 31)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set targetSdkVersion below 26 to bypass channel requirement",
      "why_fails": "Google Play requires targetSdkVersion 31+ for new apps; also, notifications still fail on API 26+ devices.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use NotificationCompat.Builder without channel ID",
      "why_fails": "NotificationCompat.Builder still requires a valid channel ID on API 26+; omitting it causes the same error.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Post notification from a Service instead of Activity",
      "why_fails": "Service context doesn't bypass channel requirement; channel creation is still needed.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Create channel before posting notification: `if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"my_channel_id\", \"My Channel\", NotificationManager.IMPORTANCE_DEFAULT); notificationManager.createNotificationChannel(channel) }`",
      "success_rate": 0.95,
      "how": "Create channel before posting notification: `if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"my_channel_id\", \"My Channel\", NotificationManager.IMPORTANCE_DEFAULT); notificationManager.createNotificationChannel(channel) }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `NotificationChannel` with a unique ID and call `createNotificationChannel()` in Application.onCreate() to ensure channel exists before any notification.",
      "success_rate": 0.93,
      "how": "Use `NotificationChannel` with a unique ID and call `createNotificationChannel()` in Application.onCreate() to ensure channel exists before any notification.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check if channel exists before posting: `val channel = notificationManager.getNotificationChannel(\"my_channel_id\"); if (channel == null) { createChannel() }`",
      "success_rate": 0.9,
      "how": "Check if channel exists before posting: `val channel = notificationManager.getNotificationChannel(\"my_channel_id\"); if (channel == null) { createChannel() }`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Create channel before posting notification: `if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"my_channel_id\", \"My Channel\", NotificationManager.IMPORTANCE_DEFAULT); notificationManager.createNotificationChannel(channel) }`",
    "Use `NotificationChannel` with a unique ID and call `createNotificationChannel()` in Application.onCreate() to ensure channel exists before any notification.",
    "Check if channel exists before posting: `val channel = notificationManager.getNotificationChannel(\"my_channel_id\"); if (channel == null) { createChannel() }`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/training/notifications/channels",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-08-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}