前言:
在平時(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é)語(yǔ)
以上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)聽