{
  "id": "android/notification-channel-required-api33",
  "signature": "android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification",
  "signature_zh": "android.app.RemoteServiceException: startForeground的通知错误：java.lang.RuntimeException: 服务通知的频道无效",
  "regex": "android\\.app\\.RemoteServiceException.*Bad notification for startForeground.*invalid channel",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Foreground service notification requires a valid notification channel on API 26+, but channel is not created or ID mismatch.",
  "root_cause_type": "generic",
  "root_cause_zh": "前台服务通知在API 26+上需要有效的通知频道，但频道未创建或ID不匹配。",
  "versions": [
    {
      "version": "Android 13 (API 33)",
      "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"
    },
    {
      "version": "Android 8.0 (API 26)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding notification permission POST_NOTIFICATIONS in manifest without creating channel",
      "why_fails": "Permission alone does not create channel; channel must be created programmatically before startForeground.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using default channel ID (e.g., 'default') without checking if it exists",
      "why_fails": "Default channel may not be created; must explicitly create channel with createNotificationChannel.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Create notification channel in Application.onCreate() or before service starts: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"service_channel\", \"Service Channel\", NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(channel) } Then use channel ID in NotificationCompat.Builder.",
      "success_rate": 0.95,
      "how": "Create notification channel in Application.onCreate() or before service starts: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"service_channel\", \"Service Channel\", NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(channel) } Then use channel ID in NotificationCompat.Builder.",
      "condition": "",
      "sources": []
    },
    {
      "action": "For services targeting API 33+, also request POST_NOTIFICATIONS permission at runtime: ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) before startForeground.",
      "success_rate": 0.9,
      "how": "For services targeting API 33+, also request POST_NOTIFICATIONS permission at runtime: ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) before startForeground.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Create notification channel in Application.onCreate() or before service starts: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(\"service_channel\", \"Service Channel\", NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(channel) } Then use channel ID in NotificationCompat.Builder.",
    "For services targeting API 33+, also request POST_NOTIFICATIONS permission at runtime: ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) before startForeground."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/develop/ui/views/notifications/channels",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-09-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}