# NotificationManager: notification not shown, missing channel. Channel 'my_channel_id' was not created.

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

## Root Cause

Notification channel not created before posting a notification on Android 8.0+ (API 26+), where channels are mandatory.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android 8.0 (API 26) | active | — | — |
| Android 9 (API 28) | active | — | — |
| Android 10 (API 29) | active | — | — |
| Android 11 (API 30) | active | — | — |
| Android 12 (API 31) | active | — | — |

## Workarounds

1. **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) }`** (95% success)
   ```
   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) }`
   ```
2. **Use `NotificationChannel` with a unique ID and call `createNotificationChannel()` in Application.onCreate() to ensure channel exists before any notification.** (93% success)
   ```
   Use `NotificationChannel` with a unique ID and call `createNotificationChannel()` in Application.onCreate() to ensure channel exists before any notification.
   ```
3. **Check if channel exists before posting: `val channel = notificationManager.getNotificationChannel("my_channel_id"); if (channel == null) { createChannel() }`** (90% success)
   ```
   Check if channel exists before posting: `val channel = notificationManager.getNotificationChannel("my_channel_id"); if (channel == null) { createChannel() }`
   ```

## Dead Ends

- **Set targetSdkVersion below 26 to bypass channel requirement** — Google Play requires targetSdkVersion 31+ for new apps; also, notifications still fail on API 26+ devices. (90% fail)
- **Use NotificationCompat.Builder without channel ID** — NotificationCompat.Builder still requires a valid channel ID on API 26+; omitting it causes the same error. (85% fail)
- **Post notification from a Service instead of Activity** — Service context doesn't bypass channel requirement; channel creation is still needed. (95% fail)
