ADB Android Debug Bridge: How to Set Up and Use It
In this article
To use the Android Debug Bridge (ADB), you must enable USB Debugging in your device's Developer Options and connect it to a computer running the Android SDK Platform-Tools. ADB is a versatile command-line tool that allows you to communicate with an Android device to install apps, debug software, pull system logs, and manage files directly from your PC, Mac, or Linux machine. It essentially acts as a bridge between your computer and the Android operating system, providing a level of control that is not available through the standard user interface.
What You'll Need
- A computer (Windows, macOS, or Linux).
- An Android device.
- A high-quality USB data cable (ensure it supports data transfer, not just charging).
- The official Android SDK Platform-Tools package.
- A computer terminal or command prompt interface.
Step-by-Step
- Download the Platform-Tools: Visit the official Android developer website and download the SDK Platform-Tools for your specific operating system. This package contains the
adb.exe(Windows) oradb(macOS/Linux) binary. Extract the downloaded ZIP file to a folder that is easy to find, such asC:\adbon Windows or your home folder on macOS/Linux. - Enable Developer Options on Android: On your Android device, open the Settings app. Navigate to the system information section (usually found in Settings > About phone or Settings > System > About phone). Locate the Build number entry. Tap the Build number seven times rapidly. You will see a toast notification stating that you are now a developer. Note that menu labels may differ slightly depending on your device manufacturer, Android version, or region.
- Enable USB Debugging: Now that Developer Options are unlocked, go back to the main Settings menu. Navigate to Settings > System > Developer options (on some devices, this is directly in the main Settings menu). Scroll down to the Debugging section and toggle the switch for USB Debugging to the On position. A prompt will appear asking if you want to allow USB debugging; select OK.
- Connect Device to Computer: Connect your Android device to your computer using the USB cable. Ensure the device is set to the correct USB mode. Swipe down the notification shade on your phone, tap the USB connection notification, and select File Transfer or MTP mode. Some devices may work with "No data transfer" selected, but File Transfer is the most reliable for initial detection.
- Open the Terminal or Command Prompt: On Windows, press the Windows key, type
cmd, and press Enter. On macOS or Linux, open the Terminal app. You need to navigate to the folder where you extracted the Platform-Tools. Use thecd(change directory) command. For example, if you extracted it to C:\adb, typecd C:\adband press Enter. - Verify the Connection: Type the following command into your terminal and press Enter:
adb devices. On your Android device, a pop-up window will appear asking "Allow USB debugging?" with the fingerprint of your computer's RSA key. Check the box that says "Always allow from this computer" and tap Allow. - Confirm Device Recognition: Run the
adb devicescommand again. You should now see a alphanumeric string followed by the worddevice. If it saysunauthorized, you haven't accepted the prompt on the phone. If the list is empty, the computer does not see the phone. - Execute Basic Commands: You can now start using ADB. To enter the device's internal shell, type
adb shell. This gives you a Linux-style command line inside the Android OS. To exit the shell, typeexit. To install an APK file from your computer, useadb install path/to/your/app.apk. To reboot the device, useadb reboot.
Common Mistakes
One of the most frequent errors is using a "charging-only" USB cable. Many cheap cables lack the internal data wires required for ADB to communicate. If your computer does not react at all when the phone is plugged in, try a different cable, preferably the one that came with the device. Another common mistake is failing to navigate to the correct folder in the command prompt. If you type adb devices and receive an error saying the command is not recognized, it means you are not in the Platform-Tools directory or ADB has not been added to your system's environment variables.
Users also frequently forget to check the phone screen for the RSA authorization prompt. ADB will not function until the device explicitly trusts the computer. If you miss this prompt or accidentally hit "Deny," the device will show as unauthorized in the terminal, and no commands will be executed. Finally, some users attempt to run ADB commands without having the correct USB drivers installed on Windows, which prevents the OS from recognizing the Android hardware.
Tips
To avoid typing cd every time you want to use ADB, you can add the Platform-Tools folder to your system's Environment Variables (Path) on Windows. This allows you to run adb from any folder in the command prompt. On macOS and Linux, you can create an alias in your .zshrc or .bashrc file to achieve the same result.
When working with multiple Android devices connected to one computer, you must specify which device you are targeting. Use the -s flag followed by the device's serial number. For example: adb -s [serial_number] shell. This prevents commands from being sent to the wrong device. Additionally, using adb logcat is an invaluable tip for developers; it streams the system log in real-time, allowing you to see exactly why an app is crashing or how the system is reacting to specific inputs.
Troubleshooting
If your device is not showing up when you run adb devices, start with the simplest fix: restart both the Android device and the computer. Ensure the USB cable is firmly seated in both ports. If that fails, try a different USB port on your computer; avoid using USB hubs or front-panel ports on a PC case, as they sometimes provide insufficient power or data stability. Connect directly to the motherboard ports on the back of the PC.
If the device is listed as unauthorized, go to the Developer Options on your phone and select "Revoke USB debugging authorizations." This clears all previously trusted computers. Unplug the phone, plug it back in, and wait for the RSA prompt to reappear on the screen. Ensure you check the "Always allow" box before tapping Allow.
For Windows users who still cannot see the device, check the Device Manager. Look for "Other Devices" or "Android Device" with a yellow warning triangle. Right-click the device, select "Update driver," and choose "Search automatically for drivers." If that doesn't work, you may need to download the specific OEM USB driver from the manufacturer's website (e.g., Samsung, Google, or Xiaomi).
If you encounter an adb server out of date error, it usually means there are multiple versions of ADB installed on your system. Close all terminal windows, open the Task Manager (Windows) or Activity Monitor (macOS), kill any process named adb, and then restart the command prompt from the official Platform-Tools folder.
Frequently Asked Questions
Do I need to root my phone to use ADB?
No, rooting is not required for ADB. ADB works with standard, unrooted devices as long as USB Debugging is enabled in the Developer Options. Rooting provides deeper access to system files, but basic ADB functions like app installation and log viewing work on any device.
Will using ADB void my warranty?
Simply using ADB to install apps or pull logs generally does not void a warranty. However, using ADB to flash custom recovery images or modify system partitions can void your warranty depending on the manufacturer's terms.
Can I use ADB wirelessly?
Yes, Android supports ADB over TCP/IP. You first connect via USB, run adb tcpip 5555, and then disconnect the cable and run adb connect [device_ip_address]. Both devices must be on the same Wi-Fi network.
What is the difference between ADB and Fastboot?
ADB is used while the Android OS is running or in recovery mode. Fastboot is a separate tool used when the device is in "Bootloader mode," which is a state before the Android OS loads. Fastboot is used for flashing partitions and unlocking bootloaders.
Why does my device disconnect randomly during ADB sessions?
This is usually caused by a faulty USB cable or a loose USB port. It can also happen if the device's power management settings put the USB port to sleep. Try using a different cable or disabling USB selective suspend in your computer's power settings.
Can I use ADB to recover data from a broken screen?
Only if USB Debugging was already enabled before the screen broke. If it was enabled and the computer was already authorized, you can use adb pull /sdcard/ to copy all files from the device to your computer.