Common ADB Commands and Troubleshooting Guide for Android Development

This article provides a comprehensive overview of frequently used Android Debug Bridge (ADB) commands, explains how to troubleshoot common connection and permission issues, and demonstrates how to manage apps, files, system information, and device operations directly from the command line.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Common ADB Commands and Troubleshooting Guide for Android Development

ADB (Android Debug Bridge) is an essential command‑line tool for Android developers and testers that communicates with a background server on TCP port 5037; it enables device inspection, app installation, file transfer, and system diagnostics.

Device listing : adb devices shows connected devices or emulators. Use adb -s <serialNumber> shell <command> to target a specific device.

Common connection problems : If no devices appear, ensure the USB vendor ID is added to adb_usb.ini. If the port is occupied (e.g., by other tools), terminate the conflicting process. If the device is unauthorized, reconnect and authorize the PC.

App installation :

Standard install: adb install <apk_path> Re‑install/overwrite: adb install -r <apk_path> Downgrade install: adb install -d <apk_path> The command returns success or an error such as INSTALL_FAILED_ALREADY_EXISTS.

App removal : adb uninstall [-k] <packageName> (the -k flag keeps data and cache).

Port forwarding : adb forward tcp:5555 tcp:8888 forwards a host port to the device.

File transfer :

Pull from device: adb pull <remote_path> <local_path> Push to device: adb push <local_path> <remote_path> If the device is rooted, files can be moved with adb push followed by adb shell su and cp.

Bug report : adb bugreport bugreport.zip (Android 6.0+) or adb bugreport > bugreport.txt (≤ 6.0) captures detailed logs for analysis.

Device information :

Model: adb shell getprop ro.product.model OS version: adb shell getprop ro.build.version.release CPU/memory: adb shell cat /proc/meminfo Serial number: adb get-serialno Shell access : adb shell opens a remote shell; exit with Ctrl+D or exit.

Package manager (pm) commands :

Clear cache/data: adb shell pm clear <packageName> List all packages: adb shell pm list packages List third‑party packages: adb shell pm list packages -3 Find packages containing a string: adb shell pm list packages *xxx* Uninstall package: adb shell pm uninstall <packageName> Get install location: adb shell pm get-install-location Activity manager (am) commands :

Start activity: adb shell am start [options] <intent> (e.g., adb shell am start -n com.example/.MainActivity)

Get launch time: adb shell am start -W -n <package>/<activity> Force‑stop app: adb shell am force-stop <packageName> Kill process: adb shell am kill <packageName> Broadcast intent: adb shell am broadcast -a <action> Monitor ANR/crash logs: adb shell am monitor Dumpsys utilities :

Memory usage for a package: adb shell dumpsys meminfo <packageName> Activity info: adb shell dumpsys activity <packageName> Battery status: adb shell dumpsys battery Current focused window: adb shell dumpsys window | findstr mCurrentFocus Miscellaneous :

Screenshot: adb shell screencap -p /sdcard/screen.png then adb pull /sdcard/screen.png Screen recording: adb shell screenrecord /sdcard/record.mp4 Reboot device: adb reboot Check root status: adb shell then su; prompt # indicates root.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DebuggingMobile DevelopmentAndroidtroubleshootingcommand-lineADB
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.