NativeScript / NativeScript/plugins
[@nativescript/background-http] packagename - illegal argument exception
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 206
- Forks
- 123
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
Issue Description
Hi guys,
When I try to use your background http to upload a file,
I noticed I am getting :
Exception java.lang.RuntimeException: Unable to create service net.gotev.uploadservice.UploadService: java.lang.IllegalArgumentException: You have to set namespace to your app package name (context.packageName) in your Application subclass
at android.app.ActivityThread.handleCreateService (ActivityThread.java:5086)
at android.app.ActivityThread.-$$Nest$mhandleCreateService
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2428)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8757)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by java.lang.IllegalArgumentException: You have to set namespace to your app package name (context.packageName) in your Application subclass
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:5073)
This is because in this file:
https://github.com/NativeScript/plugins/blob/main/packages/background-http/index.android.ts
line 30, we pass in the Utils.android.getApplication()
but the inner method is looking for Utils.android.getApplication().packageName, whereas we get the packageName by Utils.android.getApplication().getPackageName() which can be null/empty, not sure if this is a bug?
Reproduction
- uploadFile
- close the app and reopen
- app crash.
Relevant log output (if applicable)
No response
Environment
No response
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project's Code of Conduct
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in packages/background-http/index.android.ts etwa bei Zeile 30, wo Utils.android.getApplication() übergeben wird, und vergleiche diesen Wert mit dem im Bericht beschriebenen Zugriff auf den Paketnamen. Reproduziere die uploadFile-Sequenz zum Schließen und erneuten Öffnen; die Aufgabe ist abgeschlossen, wenn die App nicht mehr mit der namespace IllegalArgumentException abstürzt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, typescript
- Bereich
- mobile
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100