react-native-track-player: Android 8: IllegalStateException
I am using the latest dev branch with a few fixes on top from @nasmuris’ fork: https://github.com/nasmuris/react-native-track-player/commits/dev
I am seeing the following crashes from users on Android 8 / 8.1:
java.lang.RuntimeException:
at android.app.ActivityThread.handleUnbindService (ActivityThread.java:3487)
at android.app.ActivityThread.-wrap27 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1705)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:172)
at android.app.ActivityThread.main (ActivityThread.java:6637)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1505)
at android.app.ContextImpl.startService (ContextImpl.java:1461)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at guichaguri.trackplayer.logic.Events.dispatchEvent (Events.java:41)
at guichaguri.trackplayer.logic.MediaManager.onServiceUnbounded (MediaManager.java:271)
at guichaguri.trackplayer.logic.services.PlayerService.onUnbind (PlayerService.java:43)
at android.app.ActivityThread.handleUnbindService (ActivityThread.java:3473)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 27 (4 by maintainers)
It’s the new service policy implemented in Android 8. In my recode, I’m merging the events service and the music service together, so that won’t be a problem anymore.
@jankrah12 Yes, use the latest
devbranch, it has been fixed.@Drazail I added check for null manager in the onStartCommand method.
That worked for me
I am also trying to find a patch while we wait for a re write since I am on a similar boat with my Android 8.0 users. As I understand by changing the targetSdkVersion to 25 would you then have to enable the restrictions manually through settings?
I think guichaguri was clear about what the solution would need to be - lets have some patience and not add to this thread unless we have something of substance to add.