Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@nativescript/background-http high number of crashes #274

Open
nikoTM opened this issue May 19, 2022 · 7 comments
Open

@nativescript/background-http high number of crashes #274

nikoTM opened this issue May 19, 2022 · 7 comments

Comments

@nikoTM
Copy link

nikoTM commented May 19, 2022

I am seeing a lot of crashes with java.lang.IllegalArgumentException when calling net.gotev.uploadservice.UploadServiceConfig.getNamespace

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4673)
  at android.app.ActivityThread.access$1700 (ActivityThread.java:301)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2196)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:246)
  at android.app.ActivityThread.main (ActivityThread.java:8653)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.IllegalArgumentException: 
  at net.gotev.uploadservice.UploadServiceConfig.getNamespace (UploadServiceConfig.kt:74)
  at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationAction (UploadServiceConfig.kt:234)
  at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationActionIntentFilter (UploadServiceConfig.kt:248)
  at net.gotev.uploadservice.observer.request.NotificationActionsObserver.register (NotificationActionsObserver.kt:31)
  at net.gotev.uploadservice.UploadService.onCreate (UploadService.kt:194)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4661)

Other people seem to be having this issue as well (Vydia/react-native-background-upload#288), the proposed solution is to use net.gotev:uploadservice-okhttp:4.7.0, which background-http already uses. There are some mentions in other threads that it might be due to not creating a notification channel which is supposed to happen here

export function init() {

But I suspect it's not being called reliably since it's tied to application launch.
@triniwiz does it need to be strictly called on launch? Is it okay to check didInit when creating a session and if it hasn't initialised, try to do so?

@Bernardmyburgh5
Copy link

Yeah just installed the package and getting the same error:

Execution failed for task ':app:processDebugMainManifest'. Manifest merger failed : uses-sdk:minSdkVersion 17 cannot be smaller than version 21 declared in library [net.gotev:uploadservice:4.7.0] /home/bernard/.gradle/caches/transforms-3/aabb9fd1a360dfd19fa3dd8d0f24e04f/transformed/jetified-uploadservice-4.7.0/AndroidManifest.xml as the library might be using APIs not available in 17 Suggestion: use a compatible library with a minSdk of at most 17, or increase this project's minSdk version to at least 21, or use tools:overrideLibrary="net.gotev.uploadservice" to force usage (may lead to runtime failures)

even if i explicitly call the init function in app.js
import { init } from '@nativescript/background-http'; init();

@nikoTM
Copy link
Author

nikoTM commented May 24, 2022

Hi @Bernardmyburgh5 , this is not the same issue, you can bump your minSdkVersion to 21, in your app.gradle (App_Resources/Android/app.gradle) to get proper compatibility. The error is pretty descriptive.

@Bernardmyburgh5
Copy link

@nikoTM Thank you so much, that did fix my issue, and you are 100% right, the error is pretty descriptive, its more my knowledge of native script and native apps that is lacking. thanks for help, really appreciate it.

@triniwiz
Copy link
Member

@nikoTM it has to be called before the Application.start (usually hidden on none core flavours) is called this can work if you add it to the top of your app.ts/app.js/main.ts

@nikoTM
Copy link
Author

nikoTM commented May 31, 2022

@triniwiz I am doing that, but I still see crashes related as seen above, so I thought it would be possible to mitigate with ensuring it was called later on, but if it needs to be called before the app is started, I guess that's not possible. I will see if I can find a workaround.

@triniwiz
Copy link
Member

Which flavor are you using ?

@nikoTM
Copy link
Author

nikoTM commented May 31, 2022

@triniwiz typescript/angular, if I understood the question correctly.

alejandrogomez19000 added a commit to alejandrogomez19000/react-native-background-upload that referenced this issue Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants