Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Crashes Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException #24

Open
AntonERG opened this issue Mar 15, 2024 · 3 comments

Comments

@AntonERG
Copy link

Recently updated plugin to version 3.0.2 and in the Firebase crashlytics can see that 8 users had crashes with this logs:

Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{7c8a25b u0 com.ae.touringbee/io.github.jofr.capacitor.mediasessionplugin.MediaSessionService}

Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{7c8a25b u0 com.ae.touringbee/io.github.jofr.capacitor.mediasessionplugin.MediaSessionService}
       at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2315)
       at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2286)
       at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2611)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Caused by android.app.StackTrace
Last startServiceCommon() call for this service was made here


Caused by android.app.StackTrace: Last startServiceCommon() call for this service was made here
       at android.app.ContextImpl.startServiceCommon(ContextImpl.java:2023)
       at android.app.ContextImpl.startForegroundService(ContextImpl.java:1967)
       at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:847)
       at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:847)
       at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:1091)
       at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:749)
       at androidx.media.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:115)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
@matthewbal
Copy link

We've had the same issue, were you able to fix this by downgrading?

@AntonERG
Copy link
Author

AntonERG commented Apr 5, 2024

@matthewbal no, was you able to fix your issue by downgrading?
If yes, to which version?

@matthewbal
Copy link

Unfortunately not, we've decided to opt for a native player plugin so that we have more granular control over background play. On IOS it is impossible to start a foreground service from the background, so we need to use native there anyway.

We're implementing a plugin similar to the one mentioned in this forum post.

https://forum.ionicframework.com/t/audio-in-the-background-for-ionic-capacitor-app/234073

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants