AOSP Debugging Guide

Android Compilation#

Use the envsetup.sh script to initialize the environment: source build/envsetup.sh or . build/envsetup.sh

To view a complete list of available commands, run the following command: hmm

![img](AOSP Debugging Guide.assets/hmm.png)

Framework Debugging#


  1. VIRT: This memory usage is the address space occupied by an application, regardless of whether it is actually used or not. It is normal to allocate more memory when writing programs to avoid errors and not worry about the usage.
  2. RES: Resident memory usage. This value represents the actual memory used by the application. However, there are two small issues: some things may be stored on the swap disk (SWAP), and some memory may be shared.
  3. SHR: Shared memory. This means that this memory space may also be used by other applications.
  4. DATA: Memory occupied by data. This is the actual data space required by the program and is used during runtime.


vmstat is a command that displays system information. For example, it displays the available capacity of main memory and the operating status of the CPU. If you execute the vmstat command as is, it will display information about the current processes, memory, swap, devices, interrupts, and CPU. In addition, if you add the "-d" or "-p" option, it will display the read/write status on partitions and disks. When you specify the "-f" option, it will display the number of process creations from system startup to command execution.


cat /proc/meminfo


-b	Display capacity in bytes (default)
-k	Display capacity in kilobytes
-m	Display capacity in megabytes
-h	Display capacity with units, including G and M
-t	Also display the total of physical and swap memory


Commonly used to trace system calls and signals received during process execution.


Measures the time, user CPU time, and system CPU time spent from calling a specified command to its completion. After the output of the specified command, the measurement results are output to standard error output. The actual CPU time used by the command code is the user CPU time. Therefore, if a nonexistent command is used as a parameter for the time command, the user CPU time becomes 0. Sleep time is not included in the calculation.


Displays the size of each segment in a target file or shared library file.


Determines and displays the file type.


Resolves so files.

Skip boot animation#

adb shell settings put global device_provisioned 1


View information about ELF format files.


adb root;adb remount

Clear cache: adb logcat -c

If unable to clear, specify the buffer to clear: adb logcat -c main/system/event/kernel/all

View cache: adb logcat -g
Set maximum logcat buffer: adb logcat -G 100M

dump meminfo#

adb shell dumpsys meminfo
Or for a specific package:
adb shell dumpsys meminfo packageName


  • Print debug logs
  • Print the memory size of a variable

View CPU architecture#

adb shell getprop ro.product.cpu.abi


List of services: adb shell service list
Check if a service exists: adb shell service check SurfaceFlinger


adb shell dumpsys activity top|grep ACTIVITY

adb shell am start -n ActivityName

Get properties#

getprop: View all machine information parameters
getprop ro.serialno: View the machine's serial number
getprop ro.carrier: View the machine's CID number
getprop ro.hardware: View the machine's board code
getprop ro.bootloader: View the SPL (Hboot) version number
getprop ro.build.version.release: View the system version (8, 9, etc.)
getprop ro.build.display.id: Get the manufacturer's system version

CPU frequency#

Root permission (enter the su command directly)
cd sys/devices/system/cpu/cpu0/cpufreq
The following files are listed:

cpuinfo_cur_freq: The current working frequency of the CPU
cpuinfo_max_freq: Specifies the highest working frequency that the processor can run at (in kilohertz)
cpuinfo_min_freq: Specifies the lowest working frequency that the processor can run at (in kilohertz)


adb shell
wm size: Get the current resolution of the phone
wm density: Get the current screen density of the phone (e.g. 560dpi)

wm size 1096*2560
wm density 420

wm size reset
wm density reset

View virtual addresses#

adb root;adb remount
adb shell
ps -A|grep camera: View the process ID (e.g. 4712) of the service
cd proc/4712: Enter the folder of the process ID
more maps: View virtual memory addresses

SELinux mode#

  • adb shell setenforce 0 (Temporarily disable SELinux mode)
  • adb shell setenforce 1 (Enable SELinux mode)

Get path#

  • adb shell dumpsys SurfaceFlinger (View the running APK at the bottom)
  • adb shell pm path "com.**" (Get the path)
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.