1. logcat command
This command is the simplest and most commonly used. You can view the help. I won't say much. If you need to print the time, add the parameter -v time
adb logcat -v time
2. bugreport command
This command is also very simple, but it is very useful in practical applications. There will be detailed dumpsys, dumpstate and logcat information after booting, which is a complete log record. It is a great reference for analyzing user behavior, abnormal information, and system status. Generally, we will export the bugreport to the computer for analysis.
adb bugreport > xxx.log
3.dumpsys command
dumpsys [options]
meminfo 显示内存信息
cpuinfo 显示CPU信息
account 显示accounts信息
activity 显示所有的activities的信息
window 显示键盘,窗口和它们的关系
wifi 显示wifi信息
For example, to view the memory information of a program:
view the memory usage of the application com.tianxia.test
adb shell dumpsys meminfo com.xxx.test
4.top command
This is very convenient to view cpu information.
top -m 5 -t
5. Configuration file local.prop
At present, the configuration and use of local.prop have not been found on the Internet. I have only used the following in my work:
log.tag.SQLiteStatements=VERBOSE log.tag.SQLiteTime=VERBOSE
Add the above text to /data/local.prop, if you don't have this file, create it yourself. Then restart the phone, you can see the detailed SQL statement information of each application querying the database, which is very useful for debugging the database, analyzing and optimizing the database SQL exception.
6. strace command
7. Collect the cpu operation of the mobile phone.
Sometimes it is difficult for us to obtain the information we want by using logs. We may need to write some simple steps and execute them in the mobile phone.
Such as monitoring the cpu occupancy record cpu_log.sh:
# !/system/bin/sh
#这个脚步比较粗糙,是这么个意思
file=/sdcard/cpu/cpu_info.log
rm $file
until [ 1 -gt 10000 ]
do
echo -e "\n\n\n\n\n---------------">>$file
date >> $file
top -m 5 -n 1 >> $file
sleep 3
done
Every 3s, the cpu information of the mobile phone will be written to the cpu_info.log file in the cpu directory of the sdcard, which is convenient for our subsequent analysis.
ps: The method of use is to push to the data directory, grant executable permissions, and execute it under the shell.
##8. Collect memory data of an application
This practice is similar to the script above, but the command is different and I list it separately, because this is sometimes useful.
# !/system/bin/sh
#这个脚步比较粗糙,是这么个意思
file=/sdcard/cpu/mem_info.log
rm $file
until [ 1 -gt 10000 ]
do
echo -e "\n\n\n\n\n---------------">>$file
date >> $file
dumpsys meminfo com.tianxia.test >> $file
sleep 3
done