NativeScript / NativeScript/plugins

[background-http] App crashes due to IllegalArgumentException

未关闭
#318 9 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Latest @nativescript/background-http crashes some Android devices with You have to set namespace to your app package name (context.packageName) in your Application subclass:

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:4641)

Full trace from Google Play Console:

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4655)
  at android.app.ActivityThread.access$2800 (ActivityThread.java:251)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2319)
  at android.os.Handler.dispatchMessage (Handler.java:110)
  at android.os.Looper.loop (Looper.java:219)
  at android.app.ActivityThread.main (ActivityThread.java:8393)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1055)
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:4641)

Calling init() from the main.ts does not help this particular problem, because error occurs while having this in my main.ts:

import { init } from "@nativescript/background-http";

init();

According to https://github.com/gotev/android-upload-service/issues/510 createNotificationChannel() needs to be called explicitly.

贡献指南

打开贡献指南

从这里开始

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

调研方向

先从入口文件 main.ts 和 @nativescript/background-http 的 init() 调用开始,然后阅读关于显式调用 createNotificationChannel() 的已链接 android-upload-service issue。重现 Android 崩溃并跟踪服务启动过程;当报告的 IllegalArgumentException 不再在受影响的设备上发生时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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