經驗分享: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 即可

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章