NativeScript / NativeScript/plugins

[@nativescript/background-http] packagename - illegal argument exception

未关闭
#517 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
206
派生
123
平均合并
2 天 1 小时
30 天内合并 PR
1

描述

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
  1. uploadFile
  2. close the app and reopen
  3. app crash.
Relevant log output (if applicable)

No response

Environment

No response

Please accept these terms

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 packages/background-http/index.android.ts 大约第 30 行开始,查看传入 Utils.android.getApplication() 的位置,并将该值与报告中描述的包名访问方式进行比较。重现 uploadFile、关闭并重新打开的流程;当应用不再因 namespace IllegalArgumentException 崩溃时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, typescript
领域
mobile
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。