工欲善其事 its prerequisite, in the Android development process, in order to develop debugging, to find the needs of the problem, you must grasp the use of some common commands, here summarizes some of the most commonly used in Android development commands, altogether 15.
1, PS
List all the processes
This command is a command that is often used for Android debugging and problem finding, and outputs all processes without parameters.
All of the threads are output.
2, PRINTENV display environment variables, for example:
Printenv HOSTNAME printenv Bootclasspath
3, SetProp setting System Properties, and environment variables is not a concept, for example:
SetProp ctl.stop zygote setprop ctl.start zygote setprop persist.sys.usb.config adb
The above three commands are: Stop zygote service, start zygote service, turn on ADB debugging.
4. Getprop Get System Properties, display all properties without parameters, for example:
Getprop Sys.usb.config
5, Watchprops monitoring System Properties change when the system attributes change, the output changes the system properties.
6, start the service, its role is equivalent to:
SetProp Ctl.start <service>
7, Stop stop service
With parameters, it acts as a
SetProp Ctl.stop <service>
The function without parameters is equivalent to:
SetProp ctl.stop zygote setprop ctl.stop Surfaceflinger
8, DMESG output core debugging information, the role and cat/proc/kmsg the same
9, Sync Synchronization command, the data in the cache to write to the storage device.
For block devices, the write cache is turned on by default when mounted
If you write to the USB flash drive, if you do not call the command, it will cause some cache memory is not written to the USB flash drive, causing the file corruption situation.
10. Procrank the memory footprint of the output process, where USS (Unique Set Size) can be used to locate the process for a memory leak.
Kill
The KILL command can not only kill a process, but also send a signal to the process, such as:
Kill-3 <pid>
Will send sigquit to the process, the Android platform will output the Java stack and native stack information in the/data/anr/traces.txt, which is particularly useful for troubleshooting Java deadlock problems, but be careful when using the following two commands:
Touch /data/anr/traces.txt chmod 666/data/anr/traces.txt
Because/DATA/ANR is system-privileged, if you do not execute the above two commands before kill, if the kill is a normal user process, you will not be able to output stack information to Traces.txt because of a permissions problem.
Again such as:
Kill-9 <pid>
Send Sigkill to process, used to force end process, including zombie process.
12. Debuggerd native stack for output process
Usage: debuggerd-b <pid>
13. Dumpsys for commissioning Service
When used, it is often used
Dumpsys-l
View all of the system services, and then by similar:
Dumpsys Cpuinfo
To get the debug information for the service, which is the service's dump function that is ultimately called on the implementation of the command.
13, Netcfg View or set the current network connection status, without parameters output all known network connection status, can also be used to set up a dynamic IP, or turn off the open network connection, such as:
Get dynamic IP:
Netcfg eth0 DHCP
Close eth0:
Netcfg eth0 Down
Open eth0:
Netcfg eth0 up
14. Screencap Screen Cutting
For example, save the current screen as a PNG image to/mnt/sdcard/screen.png:
Screencap-p/mnt/sdcard/screen.png
Display Help information:
Screencap-h
15, Strace used for tracking system call, this is a powerful debugging command, here only for a brief introduction, more detailed can refer to: http://blog.chinaunix.net/uid-26285146-id-3944345.html
Example:
Strace-f-P <pid>
-P
Specifies the process PID to be traced
-F
Trace Child processes
Here are just a few of the commands that are unique or often used in Android, and there are many Linux commands that are not covered here, but are beyond the scope of this article.
Summary of common commands in Android