The Android Debug Bridge (ADB) is a versatile command-line tool that allows you to interact with Android devices. Here’s a ADB commands cheat sheet:
Connecting to a Device
Check connected devices:
adb devices
Connect to a device over USB:
adb connect <device_ip_address>
Disconnect from a device:
adb disconnect
File Management
Push a file to the device:
adb push <local_file> <device_path>
Pull a file from the device:
adb pull <device_file> <local_path>
Install an APK:
adb install <app.apk>
Uninstall an app:
adb uninstall <package_name>
Device Interaction
Open a shell on the device:
adb shell
Reboot the device:
adb reboot
Reboot into recovery mode:
adb reboot recovery
Reboot into bootloader/fastboot mode:
adb reboot bootloader
Debugging and Logging
View device log:
adb logcat
Clear logcat:
adb logcat -c
Capture bug report:
adb bugreport
Pull the last bug report from the device:
adb bugreport > bugreport.zip
Package and Activity Information
List installed packages:
adb shell pm list packages
Get package information:
adb shell pm dump <package_name>
Launch an activity:
adb shell am start -n <package_name>/<activity_name>
Screen Capture and Recording
Take a screenshot:
adb shell screencap -p > screenshot.png
Record the screen:
adb shell screenrecord --verbose /sdcard/demo.mp4
Networking
Forward a port from the device to the host:
adb forward tcp:<host_port> tcp:<device_port>
Reverse a port from the host to the device:
adb reverse tcp:<host_port> tcp:<device_port>
These commands cover a range of common ADB tasks. Remember to replace placeholders like <device_ip_address>
, <local_file>
, <device_path>
, <app.apk>
, <package_name>
, <activity_name>
, <device_file>
, and <local_path>
with the actual values relevant to your use case.