UAMP crashes with ForegroundServiceStartNotAllowedException when targeting API 31/32
See original GitHub issueThe UAMP app crashes when trying to resume the playback session using the Google Assistant if the target and compile sdk is 31 or above
Steps to reproduce it:
- Checkout the latest version of uamp and update the target and compile sdk to API 31 or 32
- Fix the compilation issues (adding flags to the manifest and some other classes)
- Open UAMP app
- Start playing something
- Pause it
- Background the app
- Open the Google Assistant and say: resume
- The app crashes:
android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.example.android.uamp.next/com.example.android.uamp.media.MusicService
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:3333)
at android.os.Parcel.createExceptionOrNull(Parcel.java:2420)
at android.os.Parcel.createException(Parcel.java:2409)
at android.os.Parcel.readException(Parcel.java:2392)
at android.os.Parcel.readException(Parcel.java:2334)
at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:6028)
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1855)
at android.app.ContextImpl.startForegroundService(ContextImpl.java:1831)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:933)
at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:701)
at com.example.android.uamp.media.MusicService$PlayerNotificationListener.onNotificationPosted(MusicService.kt:577)
at com.google.android.exoplayer2.ui.PlayerNotificationManager.startOrUpdateNotification(PlayerNotificationManager.java:1164)
at com.google.android.exoplayer2.ui.PlayerNotificationManager.handleMessage(PlayerNotificationManager.java:1409)
at com.google.android.exoplayer2.ui.PlayerNotificationManager.lambda$ZG0s-7uOzb-YtyUlp8ahx3j4wBg(Unknown Source:0)
at com.google.android.exoplayer2.ui.-$$Lambda$PlayerNotificationManager$ZG0s-7uOzb-YtyUlp8ahx3j4wBg.handleMessage(Unknown Source:2)
Does the UAMP project still needs to be updated to comply with the latest restrictions around Foreground Services introduced in API 31 ? If this is the case, do you have any idea on when this would happen?
Is it possible that the problem is within the Google Assistant app?
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6
Top Results From Across the Web
java - Stack Overflow
How to reproduce the crash. Step 1. Update your targetSdkVersion and compileSdkVersion to SDK 31. Step 2. Try to run any Foreground service ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also having this issue on one of our apps. I came here to see how Google solves the problem, only to find … they haven’t.
We have opened an issue on their Issue Tracker in case you wanna also follow that one: https://issuetracker.google.com/u/1/issues/235172948