经验分享:RuntimeException: Unable to instantiate service com.***.push.getui.GetuiPushIntentService

背景:

升级 push 服务,下线个推,切换成其他三方 push 服务,出现以下 crash:

java.lang.RuntimeException: Unable to instantiate service com.**.getui.GetuiPushIntentService: java.lang.ClassNotFoundException: Didn't find class "com.**.push.getui.GetuiPushIntentService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.**.**-L84y3CpfNvmwgLMaYeXmHQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.*.*-L84y3CpfNvmwgLMaYeXmHQ==/lib/arm, /data/app/com.*.*-L84y3CpfNvmwgLMaYeXmHQ==/base.apk!/lib/armeabi, /system/lib, /product/lib]] at android.app.ActivityThread.handleCreateService(ActivityThread.java:4136) at android.app.ActivityThread.access$2400(ActivityThread.java:273) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2055) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.*.*.push.getui.GetuiPushIntentService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.*.*-L84y3CpfNvmwgLMaYeXmHQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.*.*-L84y3CpfNvmwgLMaYeXmHQ==/lib/arm, /data/app/com.*.*-L84y3CpfNvmwgLMaYeXmHQ==/base.apk!/lib/armeabi, /system/lib, /product/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103) at android.support.v4.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:68) at android.app.ActivityThread.handleCreateService(ActivityThread.java:4131) ... 8 more

原因:我们知道广播发送是有延迟的,当我们更换 push 服务时,我们很可能会有残留广播消息还没接收完成,当用户升级之后,收到延迟的广播消息之后,接收的 service 已经被干掉,就会出现已上的 crash 异常

解决方案:

过度阶段先把com.**.getui.GetuiPushIntentService 保留,哪怕是空实现也是可以的,将残留广播消息消化掉,逐步覆盖完成之后,若干版本之后可以平滑切入,干掉残留 service 即可

 

 

 

你可能感兴趣的:(push,个推,Android)