AutoX icon indicating copy to clipboard operation
AutoX copied to clipboard

打包应用后,前端保活脚本异常

Open Boris-code opened this issue 1 year ago • 8 comments

  1. Autox.js 版本:6.3.2

  2. Autox.js 下载渠道:检查更新

  3. 问题描述:

JavaException: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=dataant.foreground shortcut=null contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x2 color=0x00000000 vis=PRIVATE)

Boris-code avatar Sep 02 '22 08:09 Boris-code

通知代码有错?

Warm-rain avatar Sep 02 '22 13:09 Warm-rain

这段代码哈,直接运行没有错,打包APP后报错。

// 保活
let KeepAliveService = {
  /** 开启 */
  start: function (idStr, nameStr) {
    try {
      idStr = idStr || ""
      let channel_id = idStr + ".foreground"
      let channel_name = nameStr + " 前台服务通知"

      let content_title = nameStr + " 正在运行中"
      let content_text = "请勿手动移除该通知"

      let ticker = nameStr + "已启动"

      let manager = context.getSystemService(android.app.Service.NOTIFICATION_SERVICE)
      let notification
      let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.getPackageName())
      if (device.sdkInt >= 26) {
        let channel = new android.app.NotificationChannel(channel_id, channel_name, android.app.NotificationManager.IMPORTANCE_DEFAULT)
        channel.enableLights(true)
        channel.setLightColor(0xff0000)
        channel.setShowBadge(false)
        manager.createNotificationChannel(channel)
        notification = new android.app.Notification.Builder(context, channel_id).setContentTitle(content_title).setContentText(content_text).setWhen(new Date().getTime()).setSmallIcon(icon).setTicker(ticker).setOngoing(true).build()
      } else {
        notification = new android.app.Notification.Builder(context).setContentTitle(content_title).setContentText(content_text).setWhen(new Date().getTime()).setSmallIcon(icon).setTicker(ticker).build()
      }
      manager.notify(1, notification)
    } catch (error) {
      console.warn("前台保活服务启动失败:" + error)
      console.warn("保活服务启动失败,不影响辅助的正常运行,继续挂机即可.")
    }
  },
  /** 停止 */
  stop: function () {
    let manager = context.getSystemService(android.app.Service.NOTIFICATION_SERVICE)
    manager.cancelAll()
  },
}

KeepAliveService.start("xxx", "xxxx")

Boris-code avatar Sep 04 '22 08:09 Boris-code

let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.getPackageName())

context.getPacketName() 改成定死 "org.autojs.autoxjs.inrt"

letsfire avatar Sep 12 '22 15:09 letsfire

问题应该不在这里

发送自我的盖乐世

-------- 原始信息 -------- 发件人: letsfire @.> 日期: 2022/9/12 23:43 (GMT+08:00) 收件人: kkevsekk1/AutoX @.> 抄送: Subscribed @.***> 主题: Re: [kkevsekk1/AutoX] 打包应用后,前端保活脚本异常 (Issue #424)

let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.getPackageName())

context.getPacketName() 改成定死 "org.autojs.autoxjs.inrt"

― Reply to this email directly, view it on GitHubhttps://github.com/kkevsekk1/AutoX/issues/424#issuecomment-1243930958, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD64RCEGXINNRBUBDS5XG7LV55FRZANCNFSM6AAAAAAQDBHXR4. You are receiving this because you are subscribed to this thread.Message ID: @.***>

kkevsekk1 avatar Sep 12 '22 16:09 kkevsekk1

图标找不到,我看了一下apk里面,图标路径是在包org.autojs.autoxjs.inrt下面。问题根本应该不是在这里

letsfire avatar Sep 13 '22 04:09 letsfire

autox菜单里不是有前台服务的选项的吗。这个保活应该已经集成了吧,通过什么配置启用,没找到文档说明

letsfire avatar Sep 13 '22 04:09 letsfire

请教 FOREGROUND_SERVICE 这个怎么配置启用

letsfire avatar Sep 13 '22 08:09 letsfire

let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.getPackageName())

context.getPacketName() 改成定死 "org.autojs.autoxjs.inrt"

这个是可用的

yswtrue avatar Sep 27 '23 14:09 yswtrue

此lssue由于长期未活动已被自动关闭,如问题任然存在,请重新打开lssue

github-actions[bot] avatar May 09 '24 23:05 github-actions[bot]