How to debug Android Devices

Debugging android devices is relatively easy compare to iOS/Windows
because android is based on Linux platform and it’s open source.

Let’s directly jump into the debugging of Android devices:

Setup Android on you system:

Let’s debug the device now:
connect your android device with system now and run following command:

  • To check the device has connected : adb devices
  • To install the app: adb install
  • To uninstall the app: adb uninstall
  • To see all the logs: adb logcat
  • To see the log from specific device:
    adb -s logcat
  • To see thread logs:
    adb logcat -v thread
  • to see the radio/telephony logs:
    adb logcat -b radio
  • To see the device events: adb logcat event
  • To see specific messages, you can use ActivityManager:
    adb logcat ActivityManager:I MyApp:D *:S
  • To filter out the logs of different level:
    adb logcat *:W
  • To enter into the device shell:
    adb shell or adb -s shell
    Now you can user most of the linux command like:
    ls -> list of files
    ps -> to see the process running
    cat -> check the file content
    cd dir/ -> Go to different location in device
  • exit -> To exit from code command
  • To see colorful logs: adb logcat -c
  • To save the logs in sdcard:
    adb root
    adb logcat -d -f /sdcard/logcat.log *:V
  • Clear the device logs: adb logact -c
  • reboot the device: adb reboot
  • To record the screen:
    adb screenrecord /sdcard/filename.mp4
    adb pull /sdcard/filename.mp4

Crash/Error Logs:

Application Not Responding(ANR):
An ANR happens when some long operation takes place in the “main” thread. This is the event loop thread, and if it is busy, Android cannot process any further GUI events in the application, and thus throws up an ANR dialog.
pull the anr file, when file created:
adb root (maybe you don’t need to run it)
adb pull /data/data/(Your Package)/traces.txt
adb shell “cp /data/anr/traces.txt /sdcard/anr_trace.txt”
adb pull /sdcard/anr_trace.txt


Whenever application get crash on device, it generate a log file which you can get from here:
adb shell “cp /data/tombstones/tombstone_00 /sdcard/tombstones_00.txt”
adb pull /sdcard/tombstones_00.txt
adb pull /data/tombstones
adb pull /data/tombstones/tombstone_00
adb pull /data/tombstones/tombstone_01

Get Memory Logs:

  • Get Memory Information:
    adb shell dumpsys meminfo ‘your apps package name’
    adb shell dumpsys meminfo ‘your apps package name’ -d
  • Memory Usage:
    adb shell cat /proc/meminfo
  • Get All process memory Information:
    adb shell dumpsys meminfo
  • Get Available or free memory information:
    adb shell vmstat
    adb shell busybox free -m
  • Get detail information:
    adb shell top
  • Another way to get the information:
    adb shell cat /proc/meminfo

Other Useful Debug Commands:

  • Get All battery information:
    adb shell dumpsys battery
  • Get Wifi information:
    adb shell dumpsys wifi
  • Get cpu inforation:
    adb shell dumpsys cpuinfo
  • Check all the broadcasting message:
    adb shell dumpsys activity broadcasts
  • If you want to see, which services available:
    adb shell service list
  • To see all the activity on device:
    adb shell dumpsys activity
  • If you want to see, what the mean of each value in dumpsys use -h as:
    adb shell dumpsys activity -h
    adb shell dumpsys meminfo -h
    adb shell dumpsys batteryinfo -h
  • If you want to check for the error in you app:
    adb shell dumpsys | grep myapp | grep Error
  • If you want to copy the heap dump from emulator:
    adb pull /data/misc/heap-dump-tm-pid.hprof address.hprof

I hope, it will help you to debug your device. I will make another post to debug the iOS app on iPhone device.

2 thoughts on “How to debug Android Devices

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s