Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ForegroundServiceStartNotAllowedException stopping playback

See original GitHub issue

We have many reports from Android 12 users claiming that the app crashes or the audio quality deteriorates with playback while the screen is off.

Here are the logs from 1 customer:

E 17/3 22:25:04 Playback service error Service.startForeground() not allowed due to mAllowStartForeground false: service
	at android.os.Parcel.readParcelable(
	at android.os.Parcel.createExceptionOrNull(
	at android.os.Parcel.createException(
	at android.os.Parcel.readException(
	at android.os.Parcel.readException(
	at ek.l.b(Unknown Source:2)
	at pj.r.onNext(
	at uj.c2$a.d(
	at uj.c2$
	at ij.b$
	at android.os.Handler.handleCallback(
	at android.os.Handler.dispatchMessage(
	at android.os.Looper.loopOnce(
	at android.os.Looper.loop(
	at java.lang.reflect.Method.invoke(Native Method)
Caused by: android.os.RemoteException: Remote stack trace:

ApplicationExitInfo(timestamp=18/03/22, 9:35 pm pid=19707 realUid=10237 packageUid=10237 definingUid=10237 user=0 reason=9 (EXCESSIVE RESOURCE USAGE) subreason=7 (EXCESSIVE CPU USAGE) status=0 importance=400 pss=158MB rss=175MB description=excessive cpu 22790 during 300121 dur=1781131 limit=2 state=empty trace=null

Device info:

App version : 7.19.2 (7566)
Sync account:
Last Sync: 2022-03-18T10:34:59.987Z
Time: 2022-03-18 23:35:09 Local
      2022-03-18 10:35:09 Utc
Background refresh: true

Phone: Google - oriole - Pixel 6 - oriole
Kernel: 5.10.43-android12-9-00007-g9771767708df-ab8009062 - abfarm-release-rbe-64-00086
Android version: 12 SDK 31
Phone ID: 929e6fab-74fe-4a75-8b4d-2fa40c562bf9

#4871871-zen #4885182-zen

Both reported that setting the battery optimization to unrestricted for Pocket Casts resolved it. There have been users, however, who have reported that updating the battery optimization setting has not fixed the issue.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

ashiagrcommented, Dec 7, 2022


Latest Cast SDK (21.2.0) includes this release note:

Fixed ForegroundServiceStartNotAllowedException with the MediaNotificationService.

The SDK version is updated in v7.28 in this PR. Hopefully, we’ll stop seeing this issue while casting. 🤞

mchowningcommented, Dec 7, 2022

🤦 I looked at the wrong PR! Sorry about that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting ForegroundServiceStartNotAllowedException #111
We want to stop the playback when the app is removed from the recent activities, so that's why we call stopSelf() there, does...
Read more >
Android 12 ForegroundServiceStartNotAllowedException ...
I believe this is a bug in Android 12, it is preventing foreground services even in situations which are supposed to be allowed....
Read more >
ForegroundServiceStartNotAllowedException when targeting 31+ and controlling playback via Google Assistant ; Comments (15) ; Duplicates (0) ; Blocking (0) ...
Read more >
Foreground services - Android Developers
Build TV playback apps. Overview. UI guidance & Leanback API. Create a catalog browser · Provide a card view · Build a details...
Read more >
Foreground service launch restrictions-Android12
If an application attempts to start a foreground service while running in the background, the ForegroundServiceStartNotAllowedException exception ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found