有時做開發的時候,用真機測試,總是看不到logcat信息 。原因是系統默認關閉了log,需要將其打開。
在撥號界面輸入*#*#2846579#*#* ,然后系統會自動彈出一個菜單,選擇工程菜單,進入后,點擊背景設置,然后選擇log設置,將默認的設置成開啟狀態,然后手機可能會自動重啟,如果不自動重啟,請手動重啟。重啟之后就行了。
http://stackoverflow.com/questions/6941710/unable-to-open-log-device-dev-log-main-no-such-file-or-directory
Dial this: *#*#2846579#*#*
Service menu will appear.
Go to “ProjectMenu” -> “Background Setting” -> “Log Setting” //Log設置中,設置LOG開關為開。
Open “Log switch” and set it to ON. // 設置log級別為Verbose
Open “Log level setting” and set the log level you wish.
Reboot the phone.
之后重啟手機就OK啦。
如果還是不行的話按照下面方法:
1.需要root權限(部分rom不需要)
2.打開logcat,並設置level
adb shell
echo 1 > /sys/kernel/logger/log_main/enable // 這里為注釋,將1寫入開關文件,1為開,0為關
echo 2 >/sys/kernel/logger/log_main/priority // 里為注釋,將代表level的2寫入優先級文件
3.重啟adb,如果使用eclipse,先關閉eclipse,再重啟adb,再啟動eclipse
adb kill-server
adb start-server
4.此時70%的logcat應該能正常工作了.如果此時logcat仍舊不工作,更新adb(只是一條指令,不需聯網,很快執行完畢)
android update adb
5.重復第3步.此時80%的logcat應該能正常工作了
6.如果logcat仍舊不工作
找到個人主目錄下的android目錄,如我的是C:\Documents and Settings\lypoint\.android
找到這個目錄下的adb_usb.ini文件,其內容默認只有三行,全為注釋,在后面添加一行,內容為0x12d1
7.重復第三步,此時90%的logcat應該能正常工作了