Small icon indicating copy to clipboard operation
Small copied to clipboard

service问题

Open xifan-xf opened this issue 8 years ago • 7 comments

  • [x] 我已阅读并理解 贡献指南,严格遵循其约定。

错误报告

你做了什么?

使用service时在onStartCommand中返回START_STICKY,在启动应用后startService,然后结束进程。 再次打开应用闪退。

你期望的结果是什么?

项目在杀死进程后能够正确启动,并正确运行。

实际结果是什么?

由于service是START_STICKY,当service被开启后会被标识,当应用进程结束后再次进入后会马上启动该service,然而此时还没有能执行到hook classloader所以会找不到service类。

Small环境

Compile-time

 gradle-small plugin : 1.1.0-beta3 (project)
            small aar : 1.1.0-beta9 (project)
          gradle core : 2.14.1
       android plugin : 2.2.3
                   OS : Windows 10 10.0 (amd64)
  Device : vivo x3t
     SDK : Android 4.2.2
     ABI : armeabi-v7a

xifan-xf avatar Jan 04 '17 03:01 xifan-xf

目前临时解决方法: 1.本地service可以设置process属性的把它放到子进程里,或者修改onStartCommand的return值为START_NOT_STICKY。 2.第三方SDK的service就麻烦了,只能看能不能设置process属性放在子进程。

xifan-xf avatar Jan 04 '17 03:01 xifan-xf

@xufan 我在 app.ok-if-stubMyLocalService 里测试,没法复现。

galenlin avatar Jan 04 '17 13:01 galenlin

是用什么版本的手机试的?我这边只有4.2.2才会出现,高版本也是没问题

xifan-xf avatar Jan 05 '17 06:01 xifan-xf

模拟器跑的,==我试下4.2的

galenlin avatar Jan 05 '17 13:01 galenlin

更新状态 已经通过在ActivityThreadHandlerCallback中处理message CREATE_SERVICE参照proivder延时安装 对Service也进行延时创建和启动

xifan-xf avatar Apr 14 '17 04:04 xifan-xf

Nexus 6P 7.0的系统,出现了同样的问题,个人猜测是由于杀掉进程后sticky service立即重启时,bundle还没有加载完成,导致ClassNotFoundException。 请问有什么解决方案?

alonelyshepherd avatar May 04 '17 13:05 alonelyshepherd

facing the same issue~ google pixel xl os 7.1.2 @alonelyshepherd

wilsonssss avatar Aug 08 '17 08:08 wilsonssss