我们在Android应用开发中,会经常遇到ANR问题。本文将从ANR产生的原因、ANR的分类、ANR问题的分析、ANR问题的常见解决办法这几个方面来介绍ANR。最后会通过分析ANR源码,了解ANR产生的过程。
THREAD_GROUP_DEFAULT | 默认线程组 |
THREAD_GROUP_BG_NONINTERACTIVE | 后台线程组 |
THREAD_GROUP_FOREGROUND | 前台线程组 |
THREAD_GROUP_SYSTEM | 系统线程组 |
04-12 11:22:11.999 1538 1648 I am_anr : [0,3026,com.android.incallui,952680013,Input dispatching timed out (Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: 0. Wait queue length: 1.)]
04-12 11:22:11.886 1538 2037 I InputDispatcher: Application is not responding: AppWindowToken{ae8dbc1 token=Token{88984a8 ActivityRecord{4e734cb u0 com.android.incallui/.InCallActivity t13049}}} - Window{d4efe8f u0 com.android.incallui/com.android.incallui.InCallActivity}. It has been 5410.4ms since event, 5000.3ms since wait started. Reason: Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: 0. Wait queue length: 1.
04-12 11:22:18.724 1538 1648 E ActivityManager: ANR in com.android.incallui (com.android.incallui/.InCallActivity)
04-12 11:22:18.724 1538 1648 E ActivityManager: PID: 3026
04-12 11:22:18.724 1538 1648 E ActivityManager: Reason: Input dispatching timed out (Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: 0. Wait queue length: 1.)
04-12 11:22:18.724 1538 1648 E ActivityManager: Load: 8.8 / 8.63 / 8.25
04-12 11:22:18.724 1538 1648 E ActivityManager: CPU usage from 0ms to 6728ms later:
04-12 11:22:18.724 1538 1648 E ActivityManager: 82% 1538/system_server: 27% user + 54% kernel / faults: 12842 minor 54 major
................
04-12 11:22:18.724 1538 1648 E ActivityManager: 37% TOTAL: 21% user + 14% kernel + 1.5% irq
----- pid 3026 at 2017-04-12 11:22:12 -----
Cmd line: com.android.incallui
"Signal Catcher" daemon prio=5 tid=2 Runnable
at android.os.BinderProxy.transactNative(Native method)
at android.os.BinderProxy.transact(Binder.java:532)
at android.app.ActivityManagerProxy.finishActivity(ActivityManagerNative.java:2964)
at android.app.Activity.finish(Activity.java:4923)
at android.app.Activity.finish(Activity.java:4941)
at com.android.incallui.InCallActivity.finish(InCallActivity.java:445)
at com.android.incallui.InCallPresenter.attemptFinishActivity(InCallPresenter.java:331)
at com.android.incallui.InCallPresenter.startOrFinishUi(InCallPresenter.java:1276)
at com.android.incallui.InCallPresenter.onCallListChange(InCallPresenter.java:488)
at com.android.incallui.CallList.notifyGenericListeners(CallList.java:528)
at com.android.incallui.CallList.finishDisconnectedCall(CallList.java:629)
at com.android.incallui.CallList.access$000(CallList.java:49)
at com.android.incallui.CallList$1.handleMessage(CallList.java:659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:5610)
at java.lang.reflect.Method.invoke!(Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)