Skip to content

[1.10.1]Fatal Exception: android.app.ForegroundServiceStartNotAllowedException #3270

@Purehi

Description

@Purehi

Version

Media3 1.10.1

More version details

No

Reproducible in the demo app?
Not tested

Devices that reproduce the issue

Xiaomi 2409BRN2CY run Android in 13/14/16
Infinix X6833B run Android in 13/14/16
Oppo CPH2755/CPH2705/CPH2333 run Android in 13/14/16
Samsung SM-A566B run Android in 13/14/16

Devices that do not reproduce the issue

Can't reproduce manually, we got the stats from Crashlytics

Reproducible in the demo app?

Not tested

Reproduction steps

We extended our playback service by your MediaSessionService, and according to the crash stats in Crashlytics, the device states were 100% in the background, we actually instantiate the media controller right after the user starts to playback, but I'm not sure what's going on under the hood.

Expected result

Since we don't have control over starting the service as foreground, I'm wondering does it make sense to catch the exception on the library side, at least to avoid crashing in this case?

Actual result

Getting the crash below

Fatal Exception: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.free.block.musicum/com.mordo.musicum.playback.PlayService
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelableInternal(Parcel.java:5277)
at android.os.Parcel.readParcelable(Parcel.java:5258)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3383)
at android.os.Parcel.createException(Parcel.java:3372)
at android.os.Parcel.readException(Parcel.java:3355)
at android.os.Parcel.readException(Parcel.java:3297)
at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:6869)
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:2170)
at android.app.ContextImpl.startForegroundService(ContextImpl.java:2135)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:903)
at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:871)
at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:563)
at androidx.media3.session.MediaNotificationManager.startForeground(MediaNotificationManager.java:525)
at androidx.media3.session.MediaNotificationManager.updateNotificationInternal(MediaNotificationManager.java:345)
at androidx.media3.session.MediaNotificationManager.onNotificationUpdated(MediaNotificationManager.java:322)
at androidx.media3.session.MediaNotificationManager.lambda$updateNotification$4(MediaNotificationManager.java:207)
at androidx.media3.common.util.Util.postOrRun(Util.java:837)
at androidx.media3.session.MediaNotificationManager.lambda$new$0(MediaNotificationManager.java:103)
at androidx.media3.session.MediaNotificationManager.lambda$updateNotification$5(MediaNotificationManager.java:206)
at androidx.media3.session.DefaultMediaNotificationProvider$OnBitmapLoadedFutureCallback.onSuccess(DefaultMediaNotificationProvider.java:694)
at androidx.media3.session.DefaultMediaNotificationProvider$OnBitmapLoadedFutureCallback.onSuccess(DefaultMediaNotificationProvider.java:670)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1102)
at android.os.Handler.handleCallback(Handler.java:1070)
at android.os.Handler.dispatchMessage(Handler.java:125)
at android.os.Looper.dispatchMessage(Looper.java:358)
at android.os.Looper.loopOnce(Looper.java:288)
at android.os.Looper.loop(Looper.java:392)
at android.app.ActivityThread.main(ActivityThread.java:10346)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972)

Media

Nothing particular, just normal audio streaming

Bug Report

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions