4

Precondition

  1. targetSdkVersion and compileSdkVersion 31.
  2. com.google.android.gms:play-services-cast:21.0.1 and com.google.android.gms:play-services-cast-framework:21.0.1

Crash

Fatal Exception: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.ondemandkorea.android/com.google.android.gms.cast.framework.media.MediaNotificationService
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
       at android.os.Parcel.readParcelable(Parcel.java:3345)
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2432)
       at android.os.Parcel.createException(Parcel.java:2421)
       at android.os.Parcel.readException(Parcel.java:2404)
       at android.os.Parcel.readException(Parcel.java:2346)
       at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:6897)
       at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1926)
       at android.app.ContextImpl.startForegroundService(ContextImpl.java:1892)
       at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:796)
       at com.google.android.gms.cast.framework.media.internal.zzp.zzg(com.google.android.gms:play-services-cast-framework@@20.1.0:33)
       at com.google.android.gms.cast.framework.media.internal.zzp.onStatusUpdated(com.google.android.gms:play-services-cast-framework@@20.1.0:1)
       at com.google.android.gms.cast.framework.media.zzbo.zzm(com.google.android.gms:play-services-cast-framework@@20.1.0:4)
       at com.google.android.gms.cast.internal.zzap.zzaa(com.google.android.gms:play-services-cast@@20.1.0:1)
       at com.google.android.gms.cast.internal.zzap.zzQ(com.google.android.gms:play-services-cast@@20.1.0:65)
       at com.google.android.gms.cast.framework.media.RemoteMediaClient.onMessageReceived(com.google.android.gms:play-services-cast-framework@@20.1.0:1)
       at com.google.android.gms.cast.zzbn.run(com.google.android.gms:play-services-cast@@20.1.0:4)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8582)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)

I have seen similar SO posts like this or this, but those were caused by starting some foreground service manually.

As you can see in the stack trace, I'm not really starting any services myself. In fact, I don't even have startForegroundService() call in my codebase. It looks like Chromecast is doing the service implementation, but I don't know where to start to debug this. Someone reported an issue in the Chromecast github, but no one has replied.

If anyone experienced similar issue, please help me debug this (or reproduce the issue).

Thank you.

Saehun Sean Oh
  • 2,103
  • 1
  • 21
  • 41
  • 1
    FWIW, that issue is unlikely to accomplish much. That is not a Chromecast GitHub repo. It is a repo for a sample app. A hopefully-relevant issue is [the one on the Google issue tracker](https://issuetracker.google.com/issues/206864385), where [somebody from Hulu suggests a workaround](https://issuetracker.google.com/issues/206864385#comment9). – CommonsWare Feb 09 '22 at 19:57
  • 1
    sigh, I was able to reproduce the issue using the same step from that thread. I guess I'll just have to wait till the fix is out. Thank you! – Saehun Sean Oh Feb 10 '22 at 00:16
  • As of today, the SDK is still not updated to fix the issue – Saehun Sean Oh Mar 17 '22 at 00:29
  • 1
    They released a new update (21.1.0) on 8th August and it will fix the crash: https://developers.google.com/cast/docs/release-notes – Ehsan Heidari Aug 17 '22 at 23:31
  • @EhsanHeidari that took a good amount of time for them :'). Thank you! – Saehun Sean Oh Aug 18 '22 at 01:07

0 Answers0