adb
is the command-line tool used for interacting with Android devices and debugging Android apps via the terminal. It's an incredibly versatile tool, full of many hidden gems. It can let you debug your apps over WiFi, copy files to/from your device, view logs, run terminal commands, and much more.
Here's a quick list of some ADB commands that I found useful.
Connections
Get a list of connected devices
Tell your device to start listening for incoming connections via WiFi, on port 5555
Connect to the device via WiFi. After this, you can now unplug it and continue debugging wirelessly.
Disconnect all wifi connections. USB connections stay active, even though it says "everything".
Using the above commands, it's possible to create script to automatically start wireless debugging. Simply plug in your device, run the script, then unplug it again. You can find an example script for Mac (and maybe Linux) here. There's also one for Windows here.
Networking
Get your device's WiFi IP address.
Forward the port 8080 from your local machine to the localhost of the device. Very useful for debugging web apps locally.
Managing apps
Install an APK from your computer onto the device.
Uninstall an app by specifying it's package name.
List installed apps. The -3
hides system apps.
Clear all app data for the specified app.
Force quit an application.
Start an app's default activity. The 1
at the end is necessary.
Files
List files in the specified folder.
Pull a file from the device. You can also specify a destination directory or file name on your computer as an extra argument.
Push a file to the device. First argument is the path on your computer, the second is the path on the device.
Logs
Display all logs from every app. See here for logcat arguments.
Filter log output to only lines that match the specified search query. Regex supported.
Other useful commands
Take a screenshot and save it to your computer.
Record your device's screen. Press Ctrl+C to stop the recording.