Tencent / Shadow

零反射全动态Android插件框架
BSD 3-Clause "New" or "Revised" License
7.47k stars 1.31k forks source link

插件中使用 WorkManager 时启动插件出错 #1308

Closed Heart-Beats closed 7 months ago

Heart-Beats commented 7 months ago

大佬,还是最新版本的 SunFlower 改造,我看启动插件就报错,报错信息如下:

16:20:44.397  7176-7176  WM-Pac...Helper com.hl.shadowdemo          D  androidx.work.impl.background.systemjob.SystemJobServicecould not be enabled
                                                                       java.lang.IllegalArgumentException: Component class androidx.work.impl.background.systemjob.SystemJobService does not exist in com.hl.shadowdemo
                                                                        at android.os.Parcel.createException(Parcel.java:1954)
                                                                        at android.os.Parcel.readException(Parcel.java:1918)
                                                                        at android.os.Parcel.readException(Parcel.java:1868)
                                                                        at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:4917)
                                                                        at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:2319)
                                                                        at androidx.work.impl.utils.PackageManagerHelper.setComponentEnabled(PackageManagerHelper.java:57)
                                                                        at androidx.work.impl.Schedulers.createBestAvailableBackgroundScheduler(Schedulers.java:158)
                                                                        at androidx.work.impl.WorkManagerImplExtKt.createSchedulers(WorkManagerImplExt.kt:86)
                                                                        at androidx.work.impl.WorkManagerImplExtKt.access$createSchedulers(WorkManagerImplExt.kt:1)
                                                                        at androidx.work.impl.WorkManagerImplExtKt$WorkManagerImpl$1.invoke(WorkManagerImplExt.kt:43)
                                                                        at androidx.work.impl.WorkManagerImplExtKt$WorkManagerImpl$1.invoke(WorkManagerImplExt.kt:43)
                                                                        at androidx.work.impl.WorkManagerImplExtKt.createWorkManager(WorkManagerImplExt.kt:45)
                                                                        at androidx.work.impl.WorkManagerImplExtKt.createWorkManager$default(WorkManagerImplExt.kt:29)
                                                                        at androidx.work.impl.WorkManagerImplExtKt.createWorkManager(Unknown Source:20)
                                                                        at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:206)
                                                                        at androidx.work.impl.WorkManagerImpl.getInstance(WorkManagerImpl.java:165)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.<init>(SystemAlarmDispatcher.java:93)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.<init>(SystemAlarmDispatcher.java:81)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmService.initializeDispatcher(SystemAlarmService.java:92)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmService.onCreate(SystemAlarmService.java:44)
                                                                        at com.tencent.shadow.core.loader.managers.UnsafePluginServiceManager.createServiceAndCallOnCreate(PluginServiceManager.kt:272)
                                                                        at com.tencent.shadow.core.loader.managers.UnsafePluginServiceManager.startPluginService(PluginServiceManager.kt:126)
                                                                        at com.tencent.shadow.core.loader.managers.PluginServiceManager.startPluginService(PluginServiceManager.kt:64)
                                                                        at com.tencent.shadow.core.loader.managers.ComponentManager.startService(ComponentManager.kt:100)
                                                                        at com.tencent.shadow.core.runtime.ShadowContext.startService(ShadowContext.java:205)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy.onReceiveShadowContext(ConstraintProxy.java:37)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy.onReceive(Unknown Source:32)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy.onReceive(ConstraintProxy.java:61)
                                                                        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
                                                                        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
                                                                        at android.os.Handler.handleCallback(Handler.java:873)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                        at android.os.Looper.loop(Looper.java:193)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6825)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
                                                                       Caused by: android.os.RemoteException: Remote stack trace:
                                                                        at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:21497)
                                                                        at com.android.server.pm.PackageManagerService.setComponentEnabledSetting(PackageManagerService.java:21268)
                                                                        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:1550)
                                                                        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4027)
                                                                        at android.os.Binder.execTransact(Binder.java:731)
16:20:44.397  7176-7176  WM-Schedulers   com.hl.shadowdemo          D  Created SystemJobScheduler and enabled SystemJobService
16:20:44.420  7176-7176  WM-Sys...patche com.hl.shadowdemo          D  Adding command Intent { act=ACTION_CONSTRAINTS_CHANGED cmp=com.hl.shadowdemo/androidx.work.impl.background.systemalarm.SystemAlarmService } (1)
16:20:44.420  7176-7355  WM-For...nnable com.hl.shadowdemo          D  The default process name was not specified.
16:20:44.421  7176-7355  WM-For...nnable com.hl.shadowdemo          D  Performing cleanup operations.
16:20:44.452  7176-7176  AndroidRuntime  com.hl.shadowdemo          D  Shutting down VM
16:20:44.456  7176-7176  AndroidRuntime  com.hl.shadowdemo          E  FATAL EXCEPTION: main
                                                                       Process: com.hl.shadowdemo:plugin, PID: 7176
                                                                       java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy@8981214
                                                                        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1401)
                                                                        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
                                                                        at android.os.Handler.handleCallback(Handler.java:873)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                        at android.os.Looper.loop(Looper.java:193)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6825)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
                                                                       Caused by: java.lang.SecurityException: Neither user 10060 nor current process has android.permission.WAKE_LOCK.
                                                                        at android.os.Parcel.createException(Parcel.java:1950)
                                                                        at android.os.Parcel.readException(Parcel.java:1918)
                                                                        at android.os.Parcel.readException(Parcel.java:1868)
                                                                        at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:400)
                                                                        at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:1507)
                                                                        at android.os.PowerManager$WakeLock.acquire(PowerManager.java:1473)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.processCommand(SystemAlarmDispatcher.java:259)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher.add(SystemAlarmDispatcher.java:168)
                                                                        at androidx.work.impl.background.systemalarm.SystemAlarmService.onStartCommand(SystemAlarmService.java:71)
                                                                        at com.tencent.shadow.core.loader.managers.UnsafePluginServiceManager.startPluginService(PluginServiceManager.kt:131)
                                                                        at com.tencent.shadow.core.loader.managers.PluginServiceManager.startPluginService(PluginServiceManager.kt:64)
                                                                        at com.tencent.shadow.core.loader.managers.ComponentManager.startService(ComponentManager.kt:100)
                                                                        at com.tencent.shadow.core.runtime.ShadowContext.startService(ShadowContext.java:205)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy.onReceiveShadowContext(ConstraintProxy.java:37)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy.onReceive(Unknown Source:32)
                                                                        at androidx.work.impl.background.systemalarm.ConstraintProxy$NetworkStateProxy.onReceive(ConstraintProxy.java:61)
                                                                        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
                                                                        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) 
                                                                        at android.os.Handler.handleCallback(Handler.java:873) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                        at android.os.Looper.loop(Looper.java:193) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6825) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860) 
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W  java.lang.Exception: call killProcess callstack! pid=7176
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at android.os.Process.killProcess(Process.java:915)
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:157)
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at org.chromium.base.JavaExceptionReporter.uncaughtException(chromium-SystemWebView.apk-default-447211456:6)
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
16:20:44.506  7176-7176  System.err      com.hl.shadowdemo          W   at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)

反编译插件后 androidx.work.impl.background.systemjob.SystemJobService 这个类以及 android.permission.WAKE_LOCK 权限都是存在的,不知为何打开插件会失败?

image

image

shifujun commented 7 months ago

在我看来就是一种正常的报错。而且这也不是这个项目的代码。没什么深究的必要。

不过如果你在改进项目的sample中遇到类似的困难,我会尽量一起看看的。