ADB
Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator or connected Android device. You can find the adb tool in android sdk/platform-tools or Download ADB Kits.
How do I find ADB located
Download the latest version of the platform-tools (about 8 MB), If you installed Android Studio (Android SDK), the default path is C:\Users\YOUR-NAME\AppData\Local\Android\Sdk in Windows.
Windows
%LocalAppData%\Android\Sdk\platform-tools
MAC
~/Library/Android/Sdk
Linux
~/Android/Sdk
ADB Debugging
adb devices
List of devices attached
List connected devices (-l for long output)
adb forward
list all forward socket connections
set up port forwarding
adb kill-server
terminates the adb server process
Wireless
adb connect
STEP 1.
Set the target device to listen for a TCP/IP connection on port 5555
disconnect the USB cable from the Android device
STEP 2.
Connect to a device over Wi-Fi.
find your Android device IP address at Settings > About phone > Status > IP address
STEP 3.
Confirm that your host computer is connected to the Android device over Wi-Fi
List of devices attached 192.168.100.12:5555 device
adb usb
Restarting in USB mode
Package Manager
adb install
app installation - push a single package to the device and install it
app installation - push multiple APKs to the device for a single package and install them
app installation - push one or more packages to the device and install them atomically
replace existing application
reinstall an existing app, keeping its data
allow test packages
allow version code downgrade
debuggable packages only
grant all runtime permissions
Grant all permissions listed in the app manifest
cause the app to be installed as an ephemeral install app
use fast deploy
always push APK to device and invoke Package Manager as separate steps
adb uninstall
remove this app package from the device
Keep the data and cache directories around after package removal
adb shell pm path
Print the path to the .apk of the given installed package name
adb shell pm clear
Deletes all data associated with a package.
Notes: clearing app data, cache
File Manager
adb pull
copy files/dirs from device
To copy a file or directory and its sub-directories from the Android device
preserve file timestamp and mode.
adb push
copy local files/directories to Android device
only push files that are newer on the host than the Android device
adb shell ls
List Files and Directories
all files including .hidden
directory, not contents
recursively list in subdirs
adb shell cd
change directory
adb shell rm
rm is a command-line utility for removing files, directories and symbolic links
Force: remove without confirmation, no error if it doesn't exist
Interactive: prompt for confirmation
Recursive: remove directory contents
Verbose
adb shell mkdir
make directories
adb shell touch
the touch command is a standard command used in UNIX/Linux operating system which is used to create, change and modify timestamps of a file
adb shell pwd
printing the current working directory
adb shell cp
copy files and directories
cp [options] <source> <dest>
STEP 1.
STEP 2.
cp /sdcard/test.txt /sdcard/demo.txt
adb shell mv
moves files or directories from one place to another
Force copy by deleting destination file
Interactive, prompt before overwriting existing DEST
No clobber (don't overwrite DEST)
Network
adb shell netstat
Display networking information.
Default is netstat -tuwx
Routing table
All sockets (not just connected)
Listening server sockets
TCP sockets
UDP sockets
Raw sockets
Unix sockets
Extended info
Don't resolve names
Wide display
Show PID/program name of sockets
adb shell ping
ping (Packet Internet Groper) is a network administration utility used to testing, and diagnosing network connectivity issues
Notes: press Ctrl-C to stop ping
Specifies the number of echo Request messages sent
Specifies the amount of time, in milliseconds, to wait for the echo Reply message that corresponds to a given echo Request message to be received
The default time-out is 4000 (4 seconds)
Interval in seconds
By default, interval is 1 second
adb shell netcfg
Network configuration.
Notes: /system/bin/sh: netcfg: not found in Android M or higher.
Display or configure network interface.
adb shell ip
get wlan0 (Wi-Fi) IP address
route table
ARP table
Logcat
adb logcat
Prints log data to the screen.
adb logcat [option] [filter-specs]
Notes: press Ctrl-C to stop monitor
adb logcat -b <Buffer>
Notes: The default value is 4. Requires the -r option.
Notes: The default value is 16. Requires the -f option.
adb logcat -v <format>
adb shell dumpsys
To dump all services
only list services, do not dump them
Get Android device battery info
adb shell dumpstate
dump Android device state.
dumpstate not working with Android 10.
dump the Android device dumpstate, dumpsys and logcat outs.
Screenshot
adb shell screencap
The screencap command is a shell utility for taking a screenshot of a device display
Notes: If FILENAME is not given, the results will be printed to stdout.
To copy screenshot from Android Device.
adb shell screenrecord
Android screenrecord v1.2. Records the device's display to a .mp4 file
Recording continues until Ctrl-C is hit or the time limit is reached
Set the video size, e.g. "1280x720". Default is the device's main display resolution (if supported), 1280x720 if not. For best results, use a size supported by the AVC encoder.
Set the video bit rate, in bits per second. Value may be specified as bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 20Mbps.
Rotates the output 90 degrees. This feature is experimental.
Add additional information, such as a timestamp overlay, that is helpful in videos captured to illustrate bugs.
Set the maximum recording time, in seconds. Default / maximum is 180
Display interesting information on stdout
Audio is not recorded with the video file. Rotation of the screen during recording is not supported. If the screen does rotate during recording, some of the screen is cut off in the recording.
System
adb root
restart adbd with root permissions
restart adbd without root permissions
adb sideload
sideload the given full OTA package
No Root Required
adb shell ps
List processes. Which processes to show (selections may be comma separated lists)
All processes
filter PIDs (--pid)
Show threads
adb shell top
Show process activity in real time
Cursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force update, R to reverse sort, Q to exit
Show threads
Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)
Maximum number of tasks to show
adb shell getprop
Gets an Android system property, or lists them all
Show property types instead of values
Get SIM Operator
Get Device IEMI
adb shell setprop
set property service
setprop <key> <value>
STEP 1.
STEP 2.
setprop service.adb.tcp.port 5555
Last updated