NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

Targeting Android Version 31 - crashes with java.lang.reflect.InvocationTargetException #281

Closed LaKing closed 2 years ago

LaKing commented 2 years ago

I had a working app, after updating everything to the latest version, my App crashes on android after starting session.multipartUpload.

System.err: java.lang.reflect.InvocationTargetException
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:58)
System.err:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
System.err:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
System.err:     at java.lang.Thread.dispatchUncaughtException(Thread.java:2200)
System.err: Caused by: java.lang.IllegalArgumentException: org.nativescript.Hangmaffia: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
System.err: 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.
System.err:     at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
System.err:     at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465)
System.err:     at android.app.PendingIntent.getActivity(PendingIntent.java:451)
System.err:     at android.app.PendingIntent.getActivity(PendingIntent.java:415)
System.err:     at com.tns.ErrorReport.startPendingErrorActivity(ErrorReport.java:157)
System.err:     at com.tns.ErrorReport.startActivity(ErrorReport.java:136)

Nativescript Vue

joshcomley commented 2 years ago

You closed this - how did you resolve it? I have the same issue

joshcomley commented 2 years ago

I just solved it by adding this to app.gradle:

android {
  defaultConfig {
    targetSdkVersion 30
  }
}
beloitdavisja commented 2 years ago

Just ran into this issue as well. Targeting SDK 30 solves it, but it shouldn't be the solution. This issue should be re-opened.

triniwiz commented 2 years ago

@beloitdavisja using the new version @nativescript/background-http also fixes the problem

beloitdavisja commented 2 years ago

@triniwiz I am using @nativescript/background-http": "^5.0.2

beloitdavisja commented 2 years ago

Ah, I see this is the old repo, apologies @triniwiz . I did update to @nativescript/background-http 6.0.0 but am receiving a different error. I'll investigate further and post in the ns plugins repo.

kennethkeim commented 2 years ago

@beloitdavisja Note the new version requires you to run an init function in the main.ts

kennethkeim commented 2 years ago

We are on version 6 and this problem is not resolved.

beloitdavisja commented 2 years ago

@kennethkeim yes. My issue with the new version is documented here: https://github.com/NativeScript/plugins/issues/283#issuecomment-1161823051

srikanthuppena98 commented 1 year ago

We are on version 6 and this problem is not resolved.

@kennethkeim @beloitdavisja @triniwiz @joshcomley I am on nativescript 6.8.0 and tns code modules 6.5.2 tns-android 6.5.3 when I target android 31 it is failing on multipart-handler, I did try updating to latest background-http 6.0.0 but now I had a different error "JS: ERROR TypeError: Cannot read property 'NotificationConfig' of undefined" let me if you resolved.

kennethkeim commented 1 year ago

Sorry, it's been a long time and I'm at a different company so don't know what came of this.

srikanthuppena98 commented 1 year ago

Ah, I see this is the old repo, apologies @triniwiz . I did update to @nativescript/background-http 6.0.0 but am receiving a different error. I'll investigate further and post in the ns plugins repo.

Yes, Even I am getting a different error after moving to @nativescript/background-http 6.0.0, the error I am getting is "JS: ERROR TypeError: Cannot read property 'NotificationConfig' of undefined" please do let me know how should I fix this. THANKS