react-native-background-actions: Not working with Android 14
I can’t get this package to work on Android 14. It’s causing the app to crash with this error:
2023-11-14 14:17:48.728 30138-30138/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.compassionclips, PID: 30138
java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@eccf065 with Intent { cmp=com.compassionclips/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.IllegalArgumentException: com.compassionclips: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4839)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalArgumentException: com.compassionclips: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
at android.os.Parcel.createExceptionOrNull(Parcel.java:3061)
at android.os.Parcel.createException(Parcel.java:3041)
at android.os.Parcel.readException(Parcel.java:3024)
at android.os.Parcel.readException(Parcel.java:2966)
at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:6568)
at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:549)
at android.app.PendingIntent.getActivity(PendingIntent.java:530)
at android.app.PendingIntent.getActivity(PendingIntent.java:494)
at com.asterinet.react.bgactions.RNBackgroundActionsTask.buildNotification(RNBackgroundActionsTask.java:45)
at com.asterinet.react.bgactions.RNBackgroundActionsTask.onStartCommand(RNBackgroundActionsTask.java:89)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4821)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 27 (3 by maintainers)
Commits related to this issue
- docs: Update version compatibility Fixes #224, fixes #223, fixes #220, fixes #219, fixes #216, fixes #209, fixes #200 — committed to GaelCO/react-native-background-actions by Rapsssito 2 years ago
@ng-ha you can use this patch for android 14
Faced the same issue. Try setting your targetSdkVersion to 33.
Yes. I replaced
shortServicewithdataSync. I also had to this to my expo config:This was my patch (generated by
pnpm patch)downgrade isn’t good answer. Do you have another solution?
That’s why I said “to my expo config”. This is my own app’s config file. But this is still needed to be patched:
found any solution ?
My app is still crashing on android 14 when i start my background service
this is my manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.wallodynamo">
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="location"/> </application> </manifest>
this worked for me. Thank you!