This will list the connected devices; if "unathorised" appears, this means that you have to unblock your mobile and accept the connection.
This indicates to the device that it has to start and adb server in port 5555:
adb tcpip 5555
Connect to that IP and that Port:
adb connect <IP>:<PORT>
If you get an error like the following in a Virtual Android software (like Genymotion):
adb server version (41) doesn't match this client (36); killing...
It's because you are trying to connect to an ADB server with a different version. Just try to find the adb binary the software is using (go to C:\Program Files\Genymobile\Genymotion and search for adb.exe)
Several devices
Whenever you find several devices connected to your machine you will need to specify in which one you want to run the adb command.
In case the adbport is only accessible from localhost in the android device but you have access via SSH, you can forward the port 5555 and connect via adb:
Prints all packages, optionally only those whose package name contains the text in <FILTER>.
adb shell pm list packages [options] <FILTER-STR>
adbshellpmlistpackages<FILTER-STR>adbshellpmlistpackages-f<FILTER-STR>#See their associated file.adbshellpmlistpackages-d<FILTER-STR>#Filter to only show disabled packages.adbshellpmlistpackages-e<FILTER-STR>#Filter to only show enabled packages.adbshellpmlistpackages-s<FILTER-STR>#Filter to only show system packages.adbshellpmlistpackages-3<FILTER-STR>#Filter to only show third party packages.adbshellpmlistpackages-i<FILTER-STR>#See the installer for the packages.adbshellpmlistpackages-u<FILTER-STR>#Also include uninstalled packages.adbshellpmlistpackages--user<USER_ID><FILTER-STR>#The user space to query.
adb shell pm path <PACKAGE>
Print the path to the APK of the given .
adbshellpmpathcom.android.phone
adb shell pm clear <PACKAGE>
Delete all data associated with a package.
adbshellpmclearcom.test.abc
File Manager
adb pull <remote> [local]
Download a specified file from an emulator/device to your computer.
adbpull/sdcard/demo.mp4./
adb push <local> <remote>
Upload a specified file from your computer to an emulator/device.
adbpushtest.apk/sdcard
Screencapture/Screenrecord
adb shell screencap <filename>
Taking a screenshot of a device display.
adbshellscreencap/sdcard/screen.png
adb shell screenrecord [options] <filename>
Recording the display of devices running Android 4.4 (API level 19) and higher.
adbshellscreenrecord/sdcard/demo.mp4adbshellscreenrecord--size<WIDTHxHEIGHT>adbshellscreenrecord--bit-rate<RATE>adb shell screenrecord --time-limit <TIME> #Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
adbshellscreenrecord--rotate# Rotates 90 degreesadbshellscreenrecord--verbose
(press Ctrl-C to stop recording)
You can download the files (images and videos) using _adb pull_
Shell
adb shell
Get a shell inside the device
adbshell
adb shell <CMD>
Execute a command inside the device
adbshellls
pm
The following commands are executed inside of a shell
pmlistpackages#List installed packagespmpath<packagename>#Get the path to the apk file of tha packageamstart [<options>] #Start an activity. Whiout options you can see the help menuamstartservice [<options>] #Start a service. Whiout options you can see the help menuambroadcast [<options>] #Send a broadcast. Whiout options you can see the help menuinput [text|keyevent]#Send keystrokes to device
Processes
If you want to get the PID of the process of your application you can execute:
adbshellps
And search for your application
Or you can do
adbshellpidofcom.your.application
And it will print the PID of the application
System
adbroot
Restarts the adbd daemon with root permissions. Then, you have to conenct again to the ADB server and you will be root (if available)
adbsideload<update.zip>
flashing/restoring Android update.zip packages.
Logs
Logcat
To filter the messages of only one application, get the PID of the application and use grep (linux/macos) or findstr (windows) to filter the output of logcat:
adblogcat|grep4526adblogcat|findstr4526
adb logcat [option] [filter-specs]
adblogcat
Notes: press Ctrl-C to stop monitor
adblogcat*:V# lowest priority, filter to only show Verbose leveladblogcat*:D# filter to only show Debug leveladblogcat*:I# filter to only show Info leveladblogcat*:W# filter to only show Warning leveladblogcat*:E# filter to only show Error leveladblogcat*:F# filter to only show Fatal leveladblogcat*:S# Silent, highest priority, on which nothing is ever printed
adb logcat -b <Buffer>
adblogcat-b# radio View the buffer that contains radio/telephony related messages.adblogcat-b# event View the buffer containing events-related messages.adblogcat-b# main defaultadblogcat-c# Clears the entire log and exits.adblogcat-d# Dumps the log to the screen and exits.adblogcat-ftest.logs# Writes log message output to test.logs .adblogcat-g# Prints the size of the specified log buffer and exits.adblogcat-n<count># Sets the maximum number of rotated logs to <count>.
Notes: Battery Historian converts that data into an HTML visualization. STEP 1adb shell dumpsys batterystats > batterystats.txtSTEP 2python historian.py batterystats.txt > batterystats.html
adbbackup [-apk] [-shared] [-system] [-all] -f file.backup# -apk -- Include APK from Third partie's applications# -shared -- Include removable storage# -system -- Include system Applciations# -all -- Include all the applicationsadbshellpmlistpackages-f-3#List packagesadbbackup-fmyapp_backup.ab-apkcom.myapp# backup on one deviceadbrestoremyapp_backup.ab# restore to the same or any other device