Android系統(tǒng)穩(wěn)定性Log分析

前言:
在平時(shí)我們開發(fā)工作中,經(jīng)常會(huì)遇到系統(tǒng)死機(jī)、黑屏卡死、凍屏等各種莫名其妙的問題,這對(duì)于我們系統(tǒng)開發(fā)工作者是一大挑戰(zhàn),除了我們需要有處理問題經(jīng)驗(yàn)和能力外,我們需要借助Google提供的各種log分析,提高我們定位處理問題的能力!


各種常見問題:

1、應(yīng)用凍結(jié)/崩潰

App這里問題比較常見,表現(xiàn)的現(xiàn)象為ANR、Crash、OOM等情況,可以通過Log日志分析:

1.捕獲通用日志
logcat log (main, system, event, radio)

2.抓取內(nèi)核日志(Dmesg/kernel logs)
adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg

3.獲取系統(tǒng)ANR日志(Trace file /data/anr) 
adb pull /data/anr/  .\anr

4.獲取系統(tǒng)墓碑日志(tombstones )
adb pull /data/tombstones  .\tombstones

5.過濾運(yùn)行時(shí)異常和DEBUG異常
adb logcat  -s AndroidRuntime,DEBUG > crash.txt
2、系統(tǒng)重啟

這屬于系統(tǒng)的穩(wěn)定系,出現(xiàn)在system server死鎖問題,然后Android的WatchDog看門狗檢測(cè)到了,然后重啟Android相關(guān)進(jìn)程導(dǎo)致,可以通過以下手段捕獲奔潰日志:

1.捕獲通用日志
logcat log (main, system, event, radio)

2.抓取內(nèi)核日志(Dmesg/kernel logs)
adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg

3.抓取bugreport信息(該信息是Android為了方便開發(fā)人員分析整個(gè)系統(tǒng)平臺(tái)和某個(gè)app在運(yùn)行一段時(shí)間之內(nèi)的所有信息,專門開發(fā)了bugreport工具)
adb shell bugreport  > bugreport.txt

4.抓取dumpstate信息(dumpstate類似于dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpstate > dumpstate.txt

5.抓取dumpsate(dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpsys > dumpsys.txt

6.抓取Binder傳輸日志
adb pull /d/binder/ .\binder

7.獲取系統(tǒng)ANR日志(Trace file /data/anr) 
adb pull /data/anr/  .\anr

8.獲取系統(tǒng)墓碑日志(tombstones )
adb pull /data/tombstones  .\tombstones
3、手機(jī)黑屏(Black screen)

終端黑屏(Black screen)這種系統(tǒng)穩(wěn)定性問題,一般出現(xiàn)問題時(shí),此時(shí)power按鍵一般能用,可以通過adb shell getevent查看到input事件信息,可以通過如下手段捕獲崩潰日志:

1.捕獲通用日志
logcat log (main, system, event, radio)

2.抓取內(nèi)核日志(Dmesg/kernel logs)
adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg

3.抓取bugreport信息(該信息是Android為了方便開發(fā)人員分析整個(gè)系統(tǒng)平臺(tái)和某個(gè)app在運(yùn)行一段時(shí)間之內(nèi)的所有信息,專門開發(fā)了bugreport工具)
adb shell bugreport  > bugreport.txt

4.抓取dumpstate信息(dumpstate類似于dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpstate > dumpstate.txt

5.抓取dumpsate(dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpsys > dumpsys.txt

6.抓取Binder傳輸日志
adb pull /d/binder/ .\binder

7.獲取系統(tǒng)ANR日志(Trace file /data/anr) 
adb pull /data/anr/  .\anr

8.獲取系統(tǒng)墓碑日志(tombstones )
adb pull /data/tombstones  .\tombstones

9.獲取meminfo日志(Meminfo log) 
adb shell cat proc/meminfo >meminfo.txt 

10.獲取Procrank信息 (Procrank log) 
adb shell procrank >procrank.txt 

11 獲取top信息日志(Top log) 
adb shell top -m 10  >top.txt 

12.Add below information: 
?Adb workable or not, ANR or not 
?CTP workable or not
 -> touch screen and observe the output of
 "adb shell getevent". 
?Display driver workable or not
 -> Use the screencast to see
 if the screen can be displayed 
?Power key/volume key work or not? 
Menu/back/home key work or not? 

13 .查看kernel的線程函數(shù)棧
adb shell "echo t > /proc/sysrq-trigger"
adb shell "cat /proc/kmsg" > ./kmsg_trigger.txt
4、系統(tǒng)卡死/屏幕卡死(System Freeze/ Touch Panel Freeze)

這是Android系統(tǒng)穩(wěn)定性里面最嚴(yán)重的,此時(shí)一般按Power按鍵、菜單鍵等都是失效的,此時(shí)可以通過adb shell getevent查看不到到input事件信息,看不到任何信息了,我們這是可以通過如下手段捕獲日志:

1.捕獲通用日志
logcat log (main, system, event, radio)

2.抓取內(nèi)核日志(Dmesg/kernel logs)
adb shell  " cat  /proc/kmsg "  或者 adb shell dmesg

3.抓取bugreport信息(該信息是Android為了方便開發(fā)人員分析整個(gè)系統(tǒng)平臺(tái)和某個(gè)app在運(yùn)行一段時(shí)間之內(nèi)的所有信息,專門開發(fā)了bugreport工具)
adb shell bugreport  > bugreport.txt

4.抓取dumpstate信息(dumpstate類似于dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpstate > dumpstate.txt

5.抓取dumpsate(dumpsys都是android提供給開發(fā)者的幫助了解系統(tǒng)運(yùn)行狀態(tài)的利器)
adb shell dumpsys > dumpsys.txt

6.抓取Binder傳輸日志
adb pull /d/binder/ .\binder

7.獲取系統(tǒng)ANR日志(Trace file /data/anr) 
adb pull /data/anr/  .\anr

8.獲取系統(tǒng)墓碑日志(tombstones )
adb pull /data/tombstones  .\tombstones

9.獲取meminfo日志(Meminfo log) 
adb shell cat proc/meminfo >meminfo.txt 

10.獲取Procrank信息 (Procrank log) 
adb shell procrank >procrank.txt 

11 獲取top信息日志(Top log) 
adb shell top -m 10  >top.txt 

12.Add below information: 
?Adb workable or not, ANR or not 
?CTP workable or not
 -> touch screen and observe the output of
 "adb shell getevent". 
?Display driver workable or not
 -> Use the screencast to see
 if the screen can be displayed 
?Power key/volume key work or not? 
Menu/back/home key work or not? 

13 .查看kernel的線程函數(shù)棧
adb shell "echo t > /proc/sysrq-trigger"
adb shell "cat /proc/kmsg" > ./kmsg_trigger.txt

14.抓取窗口信息 (Dumpsys window log)
adb shell dumpsys window > dump_window.txt

15.抓取可以 event信息(Key events log) 
adb shell getevent -rtl /dev/input/event0 按鍵事件

結(jié)語

以上Log分析是針對(duì)不同的Android系統(tǒng)穩(wěn)定性,提供抓日志方法。有了相關(guān)日志信息我們才能進(jìn)一步進(jìn)行具體日志分析,分析日志需要考研開發(fā)人員的硬實(shí)力了,有什么問題歡迎留言探討!

拓展內(nèi)容:
BugReport分析工具:
google開源
ChkBugReport開源

另一種問題定位分析方式,更精確:Android 系統(tǒng)全局Bug日志監(jiān)聽

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android系統(tǒng)最開始是為手機(jī)設(shè)計(jì)的,在機(jī)頂盒,電視,帶屏音箱等大屏上運(yùn)行后,芯片廠家做些適配,產(chǎn)品廠家也會(huì)做系...
    阿拉貢居民閱讀 8,659評(píng)論 1 14
  • 分析Android問題時(shí),經(jīng)常會(huì)遇到一些穩(wěn)定性問題。什么是穩(wěn)定性問題呢,我歸結(jié)有以下特點(diǎn), 非必現(xiàn)問題,或沒有找到...
    Android_開發(fā)閱讀 1,415評(píng)論 0 2
  • 我是黑夜里大雨紛飛的人啊 1 “又到一年六月,有人笑有人哭,有人歡樂有人憂愁,有人驚喜有人失落,有的覺得收獲滿滿有...
    陌忘宇閱讀 8,822評(píng)論 28 54
  • 信任包括信任自己和信任他人 很多時(shí)候,很多事情,失敗、遺憾、錯(cuò)過,源于不自信,不信任他人 覺得自己做不成,別人做不...
    吳氵晃閱讀 6,361評(píng)論 4 8
  • 步驟:發(fā)微博01-導(dǎo)航欄內(nèi)容 -> 發(fā)微博02-自定義TextView -> 發(fā)微博03-完善TextView和...
    dibadalu閱讀 3,393評(píng)論 1 3

友情鏈接更多精彩內(nèi)容