Last updated: March 25, 2020

Reading logs during testing Android applications often force developer or tester to use appropriate tools. One of them is: Android Device Bridge. ADB comes as a part of the standard Android SDK, it provides a terminal-based interface for interacting with your devices with Android file system. Below I added some useful commands that every tester, programmer use during deal with applications every day.

Useful commands:

  • access to Android device logs, direct output to the console
adb locat
  • this command allows to save logs in a file name you have specified, for example: abd logcat -d Users/user/storage
adb logcat -d > [filename]
  • logs on devices are erased, after that you are able to grab logs without unnecessary data
adb logcat -c - all
  • display logs with specified time
adb logcat -v time
  • reboot device
adb reboot
  • ensure that there is a server running
adb start-server
  • kill the server if it is running
adb kill-server
  • push apps from comupter onto device
adb push app /system/sd/app
  • prints: offline bootloader device
adb shell get-state
  • prints: serial-number
adb get-serialno
  • continuously print device status for a specified device
adb status-window
  • remounts the /system partition on the device read-write
adb remount
  • reboots the device, optionally into the bootloader or recovery program
adb reboot [bootloader|recovery]
  • restarts the adbd daemon listening on TCP on the specified port
adb tcpip 5555
  • list PIDs of processes hosting a JDWP transport
adb jdwp
  • run PPP over USB Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] – Eg. defaultroute debug dump local notty usepeerdns
adb ppp  [parameters]
  • above command will start an interactive shell from your machine, but running on your device
adb -s [yourdeviceserialnumberhere] shell
  • deleting existing apps on SD
adb shell rm -r /system/sd/app
adb shell rm -r /system/sd/app-private
  • return all information from the device that should be included in a bug report
adb bugreport
  • unlock bootloader, making root access possible
fastboot oem unlock
  • flash a custom recovery image to your phone
fastboot flash recovery
  • starting application using adb tools
adb shell am start -n com.package.name/.ActivityName

or

am start -n com.package.name/com.package.name.ActivityName
  • to connect to device via wifi using adb commands
adb devices
adb tcpip 5555
adb connct <IP adress of the device>:5555
adb devices
  • to print all packages
adb shell pm list packages
  • to see their associated APK file
adb shell pm list packages -f
  • to check show enabled packages
adb shell pm list packages -e
  • to show the package UID
adb shell pm list packages -U
  • to displayed routing table
adb shell netstat -r
  • to displayed all socets
adb shell netstat -a
  • to displayed listening server sockets
adb shell netstat -l
  • to display IP adress
adb shell ip addr show wlan0

Reference:

  1. CyanogenMod Wiki
  2. developer.android.com
  3. XDA Developers Forum

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee