记录第一次排查ANR经历

第一步:找到logcat中的报错记录

E/ActivityManager: ANR in com.example.testapp (com.example.testapp/.CrashTestActivity)
     PID: 2480
     Reason: Input dispatching timed out (Waiting because the touched window has not finished processing the input events that were previously delivered to it.)
     Load: 0.06 / 0.08 / 0.05
     CPU usage from 9865ms to 0ms ago:
       0.7% 1558/system_server: 0% user + 0.7% kernel / faults: 39 minor
       0.4% 1143/adbd: 0% user + 0.4% kernel / faults: 117 minor
       0.4% 1796/com.estrongs.android.pop: 0.2% user + 0.2% kernel / faults: 95 minor
       0.2% 1132/surfaceflinger: 0% user + 0.2% kernel
       0.1% 1114/kworker/0:1H: 0% user + 0.1% kernel
       0.1% 1131/rild: 0% user + 0.1% kernel
       0.1% 1682/com.android.phone: 0% user + 0.1% kernel
      +0% 2510/logcat: 0% user + 0% kernel
     0.8% TOTAL: 0.1% user + 0.7% kernel + 0% iowait
     CPU usage from 1098ms to 1603ms later:
       2% 1558/system_server: 2% user + 0% kernel
         2% 1573/ActivityManager: 2% user + 0% kernel
     0% TOTAL: 0% user + 0% kernel
 

第二步:拿到、查看traces文件(/data/anr/traces.txt)

1、人家说在这个目录下,但是我不知道怎么找,搜到取这个文件的文章:

adb pull /data/anr/traces.txt /Users/atom/Downloads/  

traces.txt文章下载到电脑的“下载中”;

2、adb指令不会用,直接在cmd中执行提示“非内部指令”:

找到adb.exe的目录配置到环境变量中的PATH中:;F:\ProgramFiles\sdk\platform-tools

一般安卓开发的,sdk目录下的platform_tools中都会有adb.exe的文件,一定要重新cmd打开指令窗才能生效。

上述指令中的atom换成自己cmd出来的Users/后面的字符就好。

3、traces.txt文件直接打开比较乱,用了“Notepad++”查看,便捷很多瞬间定位到问题代码。

(其实总感觉Androidstudio中可能有这种日志便捷展示工具的,可是不知道在哪)

 

参考文章:

https://blog.csdn.net/h610968110/article/details/89915421

https://blog.csdn.net/janronehoo/article/details/62232337

你可能感兴趣的:(开发记录)