Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

ForegroundServiceStartNotAllowedException on Android SDK 31+ #405

Closed
2 of 4 tasks
elliotdickison opened this issue Jun 17, 2022 · 1 comment
Closed
2 of 4 tasks

Comments

@elliotdickison
Copy link

elliotdickison commented Jun 17, 2022

Problem

Compiling an Android app with targetSdkVersion >= 31 results in the attached fatal when react-native-music-control attempts to start a foreground service from the background here.

Attempted fix

An attempt to fix this was made in GH-402 by adding android:foregroundServiceType="mediaPlayback" to the service declaration (released in 1.4.1), but unfortunately this did not fix the issue.

Other info

Description

  1. Sample code (provide repo url or sample code)
android.app.ForegroundServiceStartNotAllowedException: 
  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:6965)
  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 androidx.core.content.ContextCompat$Api26Impl.startForegroundService (ContextCompat.java:933)
  at androidx.core.content.ContextCompat.startForegroundService (ContextCompat.java:701)
  at com.tanguyantoine.react.MusicControlNotification$NotificationService.forceForeground (MusicControlNotification.java:215)
  at com.tanguyantoine.react.MusicControlModule$1.onServiceConnected (MusicControlModule.java:243)
  at android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:2235)
  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run (LoadedApk.java:2268)
  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:8669)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
  1. Platform ?

    • iOS
    • Android
  2. Device

  • Simulator
  • Real device
@elliotdickison elliotdickison changed the title ForegroundServiceStartNotAllowedException Android SDK 31+ ForegroundServiceStartNotAllowedException on Android SDK 31+ Jun 17, 2022
@elliotdickison
Copy link
Author

Duplicate of #400

@elliotdickison elliotdickison closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant