Introduction
Android Debug Bridge (ADB) is a powerful command-line tool that allows you to interact with an Android device from your computer's operating system. With ADB, you can install and remove apps, retrieve system logs, execute shell commands on the device, copy files, and much more. This guide will help you quickly set up ADB and start debugging, whether you're a developer or just an enthusiast looking to customize your device.
Requirements
Before you begin, make sure you have:
- A computer running Windows, Linux, or macOS.
- A USB cable that supports data transfer (not just charging).
- An Android device (version 5.0 or higher).
- Internet access to download the tools.
Step 1: Install Android SDK Platform-Tools
ADB is included in the Platform-Tools package from the Android SDK. Download it from the official website:
- Go to the SDK Platform-Tools page.
- Select the version for your operating system (Windows, Linux, macOS).
- Extract the archive to a convenient folder, for example,
C:\platform-tools(Windows) or~/platform-tools(Linux/macOS). - Add the path to this folder to the system
PATHvariable:- Windows:
Open "System" → "Advanced system settings" → "Environment Variables". Under "System variables", findPath, and add the pathC:\platform-tools. - Linux/macOS:
Add the lineexport PATH=$PATH:~/platform-toolsto the~/.bashrcor~/.zshrcfile, then runsource ~/.bashrc(orsource ~/.zshrc).
- Windows:
- Verify the installation by opening a new terminal/command prompt and running:
You should see the ADB version number.adb version
⚠️ Important for Windows: You may need USB drivers for your device. These can be found on the manufacturer's website or by using the Google USB Driver (via Android SDK Manager). If the device is not detected, install the drivers manually through Device Manager.
Step 2: Enable USB Debugging on Your Android Device
By default, the USB debugging option is hidden. To activate it:
- Open Settings → About phone (or About device).
- Find the Build number entry and tap it 7 times. You will see the message "You are now a developer!".
- Go back to the main settings menu. The Developer options entry is now available.
- In Developer options, find and enable USB debugging.
- (Optional) Enable Revoke USB debugging authorizations and then disable/re-enable USB debugging to clear old authorizations.
Step 3: Connect the Device and Authorize
- Connect the device to your computer using the USB cable.
- A dialog will appear on the device asking Allow USB debugging?. Check Always allow from this computer and tap OK.
- If the prompt does not appear, try switching the USB connection mode to File Transfer (MTP) or PTP (in the USB connection notification).
Step 4: Verify the Connection
Open a terminal or command prompt and run:
adb devices
The output will look something like:
List of devices attached
XXXXXXXXXXXX device
If your device appears with the status device, the connection is successful.
Possible statuses:
unauthorized— you have not confirmed authorization on the device. Check the dialog on your phone.offline— the device is not responding. Try reconnecting the cable or rebooting the device.- Nothing is displayed — the device is not detected. Check the cable, drivers (Windows), and that debugging is enabled.
Step 5: Basic ADB Commands
Now you can run useful commands. Here are a few examples:
- Launch device shell:
adb shell
After entering, you will be in the device's command line (like Terminal on Android). To exit, pressCtrl+Dor typeexit. - Install an APK file:
adb install path/to/file.apk
Add the-rflag to reinstall while preserving data:adb install -r app.apk. - Copy a file from the device to the computer:
adb pull /sdcard/file.txt ./ - Copy a file from the computer to the device:
adb push file.txt /sdcard/ - View logs (logcat):
adb logcat
To filter logs for your app, useadb logcat | grep "YourApp". - Reboot the device:
adb reboot - Get device information:
adb shell getprop ro.product.model # model adb shell getprop ro.build.version.release # Android version
Verification
After completing the steps, you should be able to connect to the device and run commands successfully. Check that adb devices shows your device and that basic operations (like adb shell or adb install) work without errors. If everything works—you're ready to debug!
Possible Issues
Device not showing in adb devices
- USB debugging is disabled. Go back to Step 2 and ensure the option is enabled.
- No authorization. You must confirm on the device. If you tapped "Deny", open developer options and revoke USB debugging authorizations, then reconnect.
- Cable issues. Use an original cable that supports data transfer. Try a different USB port.
- Drivers on Windows. Install drivers for your device. Google devices work with Google USB Driver; others use manufacturer drivers.
- Conflict with other software. Programs like Samsung Kies, HTC Sync, or Mi PC Suite may intercept the connection. Close them.
"error: device offline"
- Reboot the device and computer.
- Toggle USB debugging off and on on the device.
- On Windows: try installing drivers manually via Device Manager (select "Android ADB Interface").
"error: no devices/emulators"
- Ensure
adbis run as administrator (on Windows) or with sudo (on Linux/macOS) if USB device access requires elevated privileges. - Check that no other ADB instances are running (e.g., from Android Studio). End them via Task Manager.
ADB works but commands in adb shell fail
- Some commands require root access. Obtain root (if the device is rooted) or look for ADB alternatives that don't require root.
- To access protected system files, use
adb remount(requires root) oradb shell su -c "command".
Slow file transfer
- Use
adb pull/adb pushinstead ofadb shell cpfor large files. - Check USB port speed (USB 2.0 vs 3.0) and cable quality.
If the issue persists, search for the specific error in our knowledge base or on Android developer forums.