Skip to content

Unable to start service com.doublesymmetry.trackplayer.service.MusicService #2533

@mcalc001

Description

@mcalc001

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions