# android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification

- **ID:** `android/notification-channel-required-api33`
- **Domain:** android
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Foreground service notification requires a valid notification channel on API 26+, but channel is not created or ID mismatch.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android 13 (API 33) | active | — | — |
| Android 12 (API 31) | active | — | — |
| Android 8.0 (API 26) | active | — | — |

## Workarounds

1. **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.** (95% success)
   ```
   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.
   ```
2. **For services targeting API 33+, also request POST_NOTIFICATIONS permission at runtime: ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) before startForeground.** (90% success)
   ```
   For services targeting API 33+, also request POST_NOTIFICATIONS permission at runtime: ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) before startForeground.
   ```

## Dead Ends

- **Adding notification permission POST_NOTIFICATIONS in manifest without creating channel** — Permission alone does not create channel; channel must be created programmatically before startForeground. (70% fail)
- **Using default channel ID (e.g., 'default') without checking if it exists** — Default channel may not be created; must explicitly create channel with createNotificationChannel. (65% fail)
