NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
190 stars 109 forks source link

[@nativescript/background-http] Crash targeting S+ (version 31 and above) #436

Closed ebiscardi closed 1 year ago

ebiscardi commented 1 year ago

Tested on Android 13 targetSdkVersion 31

Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

StackTrace:
java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at net.gotev.uploadservice.UploadNotificationStatusConfig.getClickIntent(UploadNotificationStatusConfig.java:70)
    at net.gotev.uploadservice.UploadTask.createNotification(UploadTask.java:471)
    at net.gotev.uploadservice.UploadTask.run(UploadTask.java:152)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)
rigor789 commented 1 year ago

Make sure you are not overriding uploadServiceVersion in gradle files, and that you are on the latest version of @nativescript/background-http the underlying lib has been updated to support android 12+ and add the IMMUTABLE flag upstream:

https://github.com/gotev/android-upload-service/blob/1f07a5a5eab2e57021ef673e758b9bb2e2ccd294/uploadservice/src/main/java/net/gotev/uploadservice/extensions/ContextExtensions.kt#L225

Lib updated here: https://github.com/NativeScript/plugins/commit/802a47d7a37a84d946a5122003caa6ba18d0bb14

ebiscardi commented 1 year ago

@rigor789 Thank you very much, I solved the issue updating @nativescript/background-http dependency to the latest version