对于ANR问题,我们可以从logcat日志中搜索关键字“ANR in”
我们可以得到ANR的应用名称和原因如下:
- 08-03 09:24:36.060 2067 11175 E ActivityManager: ANR in com.baidu.BaiduMap
- (com.baidu.BaiduMap/com.baidu.baidumaps.MapsActivity)
- 08-03 09:24:36.060 2067 11175 E ActivityManager: PID: 10090
- 08-03 09:24:36.060 2067 11175 E ActivityManager: Reason: Input dispatching timed out (Waiting to send non-key event because the
- touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 2. Wait
- queue head age: 6755.2ms.)
我们还可以从logcat中获取CPU负载信息。
对于某些问题,短时间内系统负载过大会导致ANR。
如:
- 08-03 09:24:36.060 2067 11175 E ActivityManager: Load: 11.61 / 9.35 / 5.39
- 08-03 09:24:36.060 2067 11175 E ActivityManager: CPU usage from 29415ms to 0ms ago (2018-08-03 09:24:01.951 to 2018-08-03
- 09:24:31.366):
第三方