RePlugin icon indicating copy to clipboard operation
RePlugin copied to clipboard

android 8.0之后 startForeground 崩溃问题

Open chinaShawn opened this issue 5 years ago • 3 comments

问题详细描述 Detailed description of the problem

在插件中service调用startForeGround会出现崩溃问题。

复现问题步骤 Steps to reproduce the problem

  1. 用startServiceForeGround调起service
  2. service中调用startForeGorund

其它重要信息 Other important information

replugin-host-lib/gradle Version:2.3.2 rePlugin-plugin-lib/gradle Version:2.3.2

Android API Version: Android 手机型号&ROM(Phone model & ROM):

Logcat上下文 Logcat context

会出现很多如下的错误 06-27 18:06:29.928 11390-11390/com E/RePlugin.ws001: pss.isinl e: java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.work.impl.Processor androidx.work.impl.WorkManagerImpl.getProcessor()' on a null object reference at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.(SystemAlarmDispatcher.java:85) at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.(SystemAlarmDispatcher.java:72) at androidx.work.impl.background.systemalarm.SystemAlarmService.onCreate(SystemAlarmService.java:44) at com.qihoo360.replugin.component.service.server.PluginServiceServer.installServiceLocked(PluginServiceServer.java:453) at com.qihoo360.replugin.component.service.server.PluginServiceServer.access$000(PluginServiceServer.java:67) at com.qihoo360.replugin.component.service.server.PluginServiceServer$2.call(PluginServiceServer.java:399) at com.qihoo360.replugin.component.service.server.PluginServiceServer$2.call(PluginServiceServer.java:396) at com.qihoo360.replugin.base.ThreadUtils.syncToMainThread(ThreadUtils.java:50) at com.qihoo360.replugin.component.service.server.PluginServiceServer.installServiceIfNeededLocked(PluginServiceServer.java:396) at com.qihoo360.replugin.component.service.server.PluginServiceServer.startServiceLocked(PluginServiceServer.java:136) at com.qihoo360.replugin.component.service.server.PluginServiceServer$Stub.startService(PluginServiceServer.java:550) at com.qihoo360.replugin.component.service.PluginServiceClient.startService(PluginServiceClient.java:106) at com.qihoo360.loader2.PluginContext.startService(PluginContext.java:508) at androidx.work.impl.background.systemalarm.ConstraintProxy.onReceive(ConstraintProxy.java:37) at androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy.onReceive(ConstraintProxy.java:61) at com.qihoo360.replugin.component.receiver.PluginReceiverHelper$1.run(PluginReceiverHelper.java:95) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:160) at android.app.ActivityThread.main(ActivityThread.java:5541) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

出现下面的starForeGround错误 06-27 18:06:30.088 10902-10902/com.vidmate:p1 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.xx:p1, PID: 10902 java.lang.NullPointerException: class name is null at android.content.ComponentName.(ComponentName.java:63) at android.app.Service.startForeground(Service.java:651) at com.xx.download.service.DownloadService.startForeground(DownloadService.java:141) at com.xx.download.service.DownloadService.onStartCommand(DownloadService.java:118) at com.qihoo360.replugin.component.service.server.PluginServiceServer$1.handleMessage(PluginServiceServer.java:111) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:160) at android.app.ActivityThread.main(ActivityThread.java:5541) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

chinaShawn avatar Jun 27 '19 12:06 chinaShawn

我在插件里 startForegroundService 根本就启动不了服务, startService就能启动。

yezihengok avatar Dec 27 '19 06:12 yezihengok

我也遇到了,有人解决这个问题吗

buffer8848 avatar Jun 16 '22 03:06 buffer8848

我在插件里 startForegroundService 根本就启动不了服务, startService就能启动。

请问你解决了吗?

mabaixiao avatar Mar 23 '23 06:03 mabaixiao