Android Framework 框架之 GMS Crash

640?wx_fmt=gif

640?wx_fmt=gif

极力推荐Android 开发大总结文章:欢迎收藏程序员Android 力荐 ,Android 开发者需要的必备技能

640?wx_fmt=jpeg

GMS(GoogleMobile Service)包是出口国外手机中 Google 必须要预制,过 CTS 认证必须的。

本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:

  1. 多次刷机 开机向导过程中com.google.android.gms.ui Crash 解决方案

  2. 恢复出厂设置,com.google.android.gms.ui Crash 解决方案

  3. 恢复出厂,开机向导 com.google.android.setupwizard报错解决方案

  4. 恢复出厂设置或者第一次开机,先闪壁纸再显示开机向导

  5. 多次刷机com.google.android.setupwizard报错

  6. 开机向导点击 On-body com.google.android.setupwizard报错

1.多次刷机 开机向导过程中com.google.android.gms.ui Crash 解决方案

Crash Log如下:

--------- beginning of crash01-01 00:00:16.892  2210  2473 E AndroidRuntime: FATAL EXCEPTION: IPreferenceServiceThread01-01 00:00:16.892  2210  2473 E AndroidRuntime: Process: com.google.android.gms.ui, PID: 2210
01-01 00:00:16.892  2210  2473 E AndroidRuntime: java.lang.IllegalArgumentException: Service not registered: wfg@202e22a01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1329)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.app.ContextImpl.unbindService(ContextImpl.java:1495)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.content.ContextWrapper.unbindService(ContextWrapper.java:648)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.content.ContextWrapper.unbindService(ContextWrapper.java:648)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.content.ContextWrapper.unbindService(ContextWrapper.java:648)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at android.content.ContextWrapper.unbindService(ContextWrapper.java:648)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at msl.a(:com.google.android.gms@11951440:39)01-01 00:00:16.892  2210  2473 E AndroidRuntime:    at wfh.run(:com.google.android.gms@11951440:5)
--------- beginning of system

640?wx_fmt=png

当绑定服务已经解除绑定,再次解除绑定,会出现此异常

解决方案:

修改1:frameworks/base/core/java/android/content/ContextWrapper.java

640?wx_fmt=png

在ContextWrapper的 unbindService 方法中try-catch IllegalArgumentException

修改点2:frameworks/base/core/java/android/app/ContextImpl.java

640?wx_fmt=png

在ContextImpl的unbindService 方法中try-catch IllegalArgumentException

2.恢复出厂设置,com.google.android.gms.ui crash 解决方案

Crash Log如下:

12-31 21:01:26.711  3776  3776 E AndroidRuntime: FATAL EXCEPTION: main12-31 21:01:26.711  3776  3776 E AndroidRuntime: Process: com.google.android.gms.ui, PID: 377612-31 21:01:26.711  3776  3776 E AndroidRuntime: android.view.WindowManager$BadTokenException:
                                                  Unable to add window -- token android.os.BinderProxy@f176911 is not valid; is your activity running?12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at android.view.ViewRootImpl.setView(ViewRootImpl.java:567)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at android.app.Dialog.show(Dialog.java:319)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at com.google.android.location.network.ConfirmAlertChimeraActivity.a(:com.google.android.gms:164)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at rzo.onServiceConnected(:com.google.android.gms:71)12-31 21:01:26.711  3776  3776 E AndroidRuntime:    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1223)

640?wx_fmt=png

Unable to add window -- token android.os.BinderProxy@f176911 is not valid; is your activity running

解决方案如下

在 ViewRootImpl类中,解决恢复出厂设置后的问题frameworks/base/core/java/android/view/ViewRootImpl.java

640?wx_fmt=png

Unable to add window -- token android.os.BinderProxy@f176911 is not valid; is your activity running?

3.恢复出厂,开机向导 com.google.android.setupwizard报错解决方案

Crash Log如下:

--------- beginning of crash01-01 12:00:00.918  1583  1583 E AndroidRuntime: FATAL EXCEPTION: main01-01 12:00:00.918  1583  1583 E AndroidRuntime: Process: com.google.android.setupwizard, PID: 158301-01 12:00:00.918  1583  1583 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.TIME_SET flg=0x25200010 } in com.google.android.setupwizard.time.DateTimeMonitor$1@746560101-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52497(LoadedApk.java:1323)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:790)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6523)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)01-01 12:00:00.918  1583  1583 E AndroidRuntime: Caused by: java.util.ConcurrentModificationException01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at java.util.ArrayList$Itr.next(ArrayList.java:860)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at com.google.android.setupwizard.time.DateTimeMonitor.updateStatus(DateTimeMonitor.java:134)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at com.google.android.setupwizard.time.DateTimeMonitor.-wrap0(Unknown Source:0)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at com.google.android.setupwizard.time.DateTimeMonitor$1.onReceive(DateTimeMonitor.java:73)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52497(LoadedApk.java:1313)01-01 12:00:00.918  1583  1583 E AndroidRuntime:    ... 9 more
--------- beginning of system

640?wx_fmt=png

ConcurrentModificationException

解决方案如下:

此问题关键在于解决ConcurrentModificationException,但是没有源码,此问题还未完全解决,尝试规避方案如下:/frameworks/base/core/java/android/app/LoadedApk.java

640?wx_fmt=png

throw new RuntimeException 异常没有被try-catch 导致crash

4.恢复出厂设置或者第一次开机,先闪壁纸再显示开机向导

解决方案如下:

主要修改KeyguardServiceDelegate这个类。frameworks/base/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java

  • 修改点1:

在此类中添加判断方法,获取手机DEVICE_PROVISIONED状态信息。

640?wx_fmt=png

在此类中添加判断方法

  • 修改点2:

此类的构造方法中,如果获取到的为true,先隐藏

640?wx_fmt=png

此类的构造方法中,如果获取到的为true,先隐藏

  • 修改点3:

onScreenTurningOn 中判断显示

640?wx_fmt=png

onScreenTurningOn 中判断显示

640?wx_fmt=png

系统原生显示与隐藏方法

5. 多次刷机com.google.android.setupwizard报错

Crash Log如下:

--------- beginning of crash
12-12 15:19:11.984  1471  1471 E AndroidRuntime: FATAL EXCEPTION: main
12-12 15:19:11.984  1471  1471 E AndroidRuntime: Process: com.google.android.setupwizard, PID: 1471
12-12 15:19:11.984  1471  1471 E AndroidRuntime: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.wizard.NEXT (has extras) }
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1843)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1557)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.app.Activity.startActivityForResult(Activity.java:4228)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.app.Activity.startActivityForResult(Activity.java:4187)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at com.google.android.setupwizard.BaseActivity.startActivityForResult(BaseActivity.java:665)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at com.google.android.setupwizard.BaseActivity.nextAction(BaseActivity.java:651)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at com.google.android.setupwizard.BaseActivity.nextAction(BaseActivity.java:637)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at com.google.android.setupwizard.user.SuggestedActionsActivity.onItemSelected(SuggestedActionsActivity.java:226)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at com.android.setupwizardlib.items.RecyclerItemAdapter$1.onClick(RecyclerItemAdapter.java:106)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.view.View.performClick(View.java:5624)
12-12 15:19:11.984  1471  1471 E AndroidRuntime:    at android.view.View$PerformClick.run(View.java:22285)

640?wx_fmt=png

com.google.android.setupwizard 报错log

解决方案如下:

在Instrumentation 类中对Google 开机向导进行特殊处理。/frameworks/base/core/java/android/app/Instrumentation.java

640?wx_fmt=png

Instrumentation 类中对Google 开机向导进行特殊处理下

6. 开机向导点击 On-body com.google.android.setupwizard报错

Crash Log如下:

--------- beginning of crash12-31 19:00:26.668  2010  2010 E AndroidRuntime: FATAL EXCEPTION: main12-31 19:00:26.668  2010  2010 E AndroidRuntime: Process: com.google.android.setupwizard, PID: 201012-31 19:00:26.668  2010  2010 E AndroidRuntime: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.gms/com.google.android.gms.trustagent.discovery.OnbodyPromotionActivity}; have you declared this activity in your AndroidManifest.xml?12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.app.Activity.startActivityForResult(Activity.java:4229)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.app.Activity.startActivityForResult(Activity.java:4188)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at com.google.android.setupwizard.BaseActivity.startActivityForResult(BaseActivity.java:665)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at com.google.android.setupwizard.BaseActivity.startFirstRunActivityForResult(BaseActivity.java:719)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at com.google.android.setupwizard.user.SuggestedActionsActivity.onItemSelected(SuggestedActionsActivity.java:217)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at com.android.setupwizardlib.items.RecyclerItemAdapter$1.onClick(RecyclerItemAdapter.java:106)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.view.View.performClick(View.java:5675)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.view.View$PerformClick.run(View.java:22641)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:836)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:103)12-31 19:00:26.668  2010  2010 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:203)

640?wx_fmt=png

Unable to find explicit activity class Log

解决方案如下:

640?wx_fmt=png

com.google.android.setupwizard 解决方案

640?wx_fmt=jpeg

至此,本篇已结束,如有不对的地方,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!

640?wx_fmt=jpeg

如有侵权,请联系小编,小编对此深感抱歉,届时小编会删除文章,立即停止侵权行为,请您多多包涵。

640?wx_fmt=other

既然都看到这里,领两个红包在走吧!以下两个红包每天都可以领取

1.支付宝搜索 522398497,或扫码支付宝红包海报。

支付宝扫一扫,每天领取大红包

2.微信红包,微信扫一扫即可领取红包

微信扫一扫,每天领取微信红包

小礼物走一走,来简书关注我

posted @ 2018-12-11 12:49  程序员Android的博客  阅读(122)  评论(0编辑  收藏  举报