diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-23 01:07:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-23 01:07:12 +0300 |
| commit | b9de6316f5308eb467c1ab01d8193eb7945dafad (patch) | |
| tree | 3d4244cfed1e7d42e8a53529edea0e64be703d55 /player-android | |
| parent | 8d450ee93f095cfd2c5374b181d34ead9b49d502 (diff) | |
Configure audio_service notification icon so playback does not crashmain
Android refuses to post a foreground-service notification without a
small-icon drawable; without androidNotificationIcon set, the very
first AudioPlayer.play() triggers a FATAL "Invalid notification
(no valid small icon)" the moment audio_service tries to publish
the media-session metadata, killing the app process.
Re-use drawable/ic_launcher — the project's existing launcher icon —
as the small notification icon. A dedicated monochrome silhouette
would be more polished, but the launcher icon is good enough to
unblock playback today.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'player-android')
| -rw-r--r-- | player-android/lib/main.dart | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/player-android/lib/main.dart b/player-android/lib/main.dart index 3358383..4a8ca69 100644 --- a/player-android/lib/main.dart +++ b/player-android/lib/main.dart @@ -35,6 +35,13 @@ void main() async { config: const AudioServiceConfig( // Notification channel name shown in Android Settings → App info. androidNotificationChannelName: 'Player Audio', + // Required by audio_service: Android refuses to post a notification + // without a small-icon drawable. Re-use the launcher icon — it is a + // resource the project already ships and AudioService accepts any + // drawable here. Without this the foreground service fails with + // "Invalid notification (no valid small icon)" and crashes the app + // when AudioPlayer.play() triggers media-session metadata. + androidNotificationIcon: 'drawable/ic_launcher', // Keep the service alive while the notification is visible so the OS // does not kill the process when the user swipes the app away. androidStopForegroundOnPause: false, |
