-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Describe the Bug
We’re seeing a high-volume crash on Android when starting playback with react-native-track-player:
Fatal Exception: java.lang.RuntimeException
Unable to start service com.doublesymmetry.trackplayer.service.MusicService@ef92d81 with null:
android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service tv.liverpoolfc/com.doublesymmetry.trackplayer.service.MusicService
It appears that startForeground() is being invoked when the service is not allowed to start in that state — likely due to Android’s restrictions on foreground services being launched from background.
Steps To Reproduce
How can someone else reproduce this bug?
Code To Reproduce
import TrackPlayer from 'react-native-track-player';
import TrackPlayerService from './src/service/audio/track-player-service';
import 'expo-router/entry';
if (__DEV__) {
require('./ReactotronConfig');
}
TrackPlayer.registerPlaybackService(() => TrackPlayerService);
Environment Info:
• Expo: ~51.0.39
• React Native: 0.74.5
• react-native-track-player: 4.1.1
• Device: Real Android devices (Android 12, 13, 14)
• Simulator: Not the source of crash
• OS: Android (where the crash occurs)
How I can Help
What can you do to help resolve this?
leiferikbjorkli