ADB, an Android debug bridge is a command line tool which is allows android developers to communicate with emulator or physical devices which are connected to machine through usb cable or wifi pairing. This Adb will included in Android SDK packages.
Using adb we can manage
The "adb" command tool represented by the "adb.exe" file in the ./platform-tools folder. We have different commands to check different options with "adb" tool quickly:
1. Run the Android emulator through the AVD Manager and wait for the emulator to be fully booted.
2. Go to a Windows command window and run the following commands
C:\>cd \local\android-sdk-windows\platform-tools C:\local\android-sdk-windows\platform-tools>adb version Android Debug Bridge version 1.0.41 Version 33.0.3-9176374 Installed as /usr/local/bin/adb |
On Mac will be like below
To use adb with a device connected over USB/ Emulator, we must enable USB debugging in the device system settings, under Developer options. On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, enable Developer options.
From Android 11 and higher versions of devices supports deploying and debugging apps wirelessly from our workstation using Android Debug Bridge (adb). Example we can deploy and debug applications on real devices without USB connection, it will connect over wifi. This eliminates the need to deal with common USB connection issues, such as driver installation. We will learn more about android wifi pairing in the comming chapters.
adb devices |
Lists connected devices |
adb devices -l |
Lists connected devices and kind |
adb root |
Restarts adbd with root permissions |
adb start-server |
Starts the adb server |
adb kill-server |
Kills the adb server |
adb remount |
Remounts file system with read/write access |
adb reboot |
Reboots the device |
adb reboot bootloader |
Reboots the device into fastboot |
adb disable-verity |
Reboots the device into fastboot |
adb logcat |
Starts printing log messages to stdout |
adb logcat -g |
Displays current log buffer sizes |
adb logcat -G <size> |
Sets the buffer size (K or M) |
adb logcat -c |
Clears the log buffers |
adb logcat *:V |
Enables ALL log messages (verbose) |
adb logcat -f <filename> |
Dumps to specified file |
adb push <local> <remote> |
Copies the local to the device at remote |
adb pull <remote> <local> |
Copies the remote from the device to local |
adb shell <command> |
Runs the specified command on device (most unix commands work here) |
adb shell wm size |
Displays the current screen resolution |
adb shell wm size WxH |
Sets the resolution to WxH |
adb shell pm list packages |
Lists all installed packages |
adb shell pm list packages -3 |
Lists all installed 3rd-party packages |
adb shell monkey -p app.package.name |
Starts the specified package |