Debugging Android applications through ADB (Android Debug Bridge) is an integral part of working in Android Studio. This tool allows you to manage the device from your computer, install APKs, view logs, and even restore the system after failures. But many encounter problems already at the startup stage: either the drivers are not installed, the device is not detected, or the commands produce errors.
If you have never worked with ADB, do not be alarmed: the setup process is simpler than it seems. In this article we will go through everything step by step - from installation Android SDK Platform-Tools to execution of basic commands. And if you are an experienced developer, you will find rare tricks here, for example, how to run adb without superuser rights or connect to a device via Wi-Fi.
Important: ADB works not only in Android Studio, but also as a separate tool through the command line. We will look at both options so that you can choose the one that is convenient for you.
Before you start, make sure that your device supports USB debugging (the setting is hidden in the developer menu). If this item is missing, no problem: itโs easy to activate, and weโll show you how.
1. Preparation: enable USB debugging on the Android device
Without this step ADB it simply wonโt see your smartphone or tablet. The procedure is the same for most devices on Android 5.0 and newer, but may differ slightly on custom firmware (for example, MIUI or ColorOS).
First you need to activate developer menu:
- Open
Settings โ About phone. - Find the item
Build numberand tap on it 7 times in a row. A notification โYou have become a developer!โ will appear. - Return to the main settings menu - a new section will appear there
For Developers.
Now we enable debugging itself:
- Go to
Settings โ System โ For developers(on some devices the path may beAdvanced โ For developers). - Find the option
USB debuggingand activate it. - Confirm the permission in the appeared window.
โ ๏ธ Attention: On devices Xiaomi, Oppo and Vivo you may need to additionally enableOEM unlockingin the same developer menu. Without this, some ADB commands (for example,fastboot) will not work.
After connecting the device to the computer, you will be asked to trust this PC - be sure to click "Allow". If you do not do this, ADB will not be able to establish a connection.
โ๏ธ Preparing the device for ADB
2. Installing Android SDK Platform-Tools
ADB is part of the package Android SDK Platform-Toolswhich can be installed in two ways: via Android Studio or manually from the official website. We will consider both options.
Method 1: Installation via Android Studio (recommended for developers)
- Open Android Studio and go to
Tools โ SDK Manager. - In the window that opens, select the tab
SDK Tools. - Tick the checkbox
Android SDK Platform-Toolsand clickApply. - Wait for the download and installation to complete.
Method 2: Manual installation (for users without Android Studio)
- Download the archive Platform-Tools from official website (select the version for your OS: Windows, macOS or Linux).
- Extract the archive into a convenient folder, for example
C:\platform-tools(Windows) or/Users/yourname/platform-tools(macOS/Linux). - Add the folder path to the environment variable
PATHto runadbfrom any directory.
After installation, check the functionality by running the command in the terminal:
adb version
If you see the version (for example, Android Debug Bridge version 1.0.41) - everything is installed correctly.
โ ๏ธ Attention: On Windows, you may need to install drivers for your device. If adb devices gives an empty list, download the drivers. from the manufacturer's website (for example, Samsung USB Driver or Google USB Driver).
3. Basic ADB commands: what can be done with the device
Now that the connection is established, let's look at the basic commands. All of them are executed in the terminal (or Command Prompt on Windows).
Checking connected devices:
adb devices
If the device is detected, you will see its serial number with status deviceIf instead it is written unauthorized โcheck whether you have enabled debugging on phone.
Installing the application (APK):
adb install path/to/file.apk
Example: adb install app-debug.apk. To reinstall the application while saving the data, add the flag -r:
adb install -r app-debug.apk
View logs in real time:
adb logcat
To filter logs by tag (for example, to debug your application), use:
adb logcat | grep "YourTag"
Copying files from the device to the PC (and vice versa):
adb pull /path/on/device/file C:/path/on/pc
adb push C:/path/on/pc/file /path/on/device
Rebooting the device in different modes:
- ๐ Normal reboot:
adb reboot - ๐ ๏ธ Reboot to
fastboot:adb reboot bootloader - ๐ฑ Reboot to
recovery:adb reboot recovery
Uninstall the application:
adb uninstall package name
To find out the package name, use:
adb shell pm list packages | grep "keyword"
If the command adb is not recognized, make sure that the folder with platform-tools is added to the variable PATHOn Windows, you can temporarily open the terminal directly in this. folder (press Shift + right mouse button โ โOpen command windowโ)
4. Wi-Fi connection: how to get rid of the USB cable
Wi-Fi debugging is convenient when you need to test an application on a tablet or device without a USB-C port. However, for the first connection, a cable. you will still need it.
Step 1: Connect the device via USB and check the connection
adb devices
Make sure that the device appears in the list.
Step 2: Switch ADB to TCP/IP mode
adb tcpip 5555
Port 5555 can be replaced with any free one (for example, 5556), if the standard one is busy.
Step 3: Connect via Wi-Fi
adb connect IP_device:5555
To find out the IP address of the device, do:
adb shell ip route
Or look in the Wi-Fi settings on the device itself.
Step 4: Disconnect the USB cable
Now all commands adb will work over a wireless network. To return to USB mode, do:
adb usb
โ ๏ธ Attention: After rebooting the device or turning off Wi-Fi, the connection will be lost. You will have to repeat steps 1โ3. To avoid this, use apps like ADB WiFi from Google Playthat automate the process.
What what to do if the Wi-Fi connection is lost?
The problem may be in the router (check your DHCP settings) or in Android power saving (disable battery optimization for ADB in the developer settings).
5. Common ADB errors and how to fix them
Even if correct setup ADB sometimes produces errors. We have collected the most common of them and ways to solve them.
| Error | Cause | Solution |
|---|---|---|
device unauthorized |
Debug permission not given | A request will appear on the device - click โAllowโ. If there is no request, check the cable or reconnect the device. |
no devices/emulators found |
The device is not connected or the drivers are not installed | Check the USB cable, install the drivers, restart adb server command adb kill-server && adb start-server. |
protocol fault (no status) |
Protocol failure (often when connecting via Wi-Fi) | Restart the ADB server and reconnect. If the error remains, change the port. |
insufficient permissions |
Insufficient rights (for example, for commands su) |
Get root access or run Android Studio as administrator. |
Error: adb: command not found (Linux/macOS)
This means that the system does not find executable file adb. Solutions:
- ๐ Make sure that the folder
platform-toolshas been added toPATH. - ๐ Restart the terminal after adding to
PATH. - ๐ง On Linux you may need to install package
android-tools-adbvia the package manager.
Error: the device connects, but the commands do not work
Sometimes adb devices shows the device, but commands like adb install issue error: closed. Reasons:
- ๐ Problems with the USB port or cable (try a different cable).
- ๐ฑ The mode is turned on on the device
Only charging(check the notification when connecting). - ๐ ADB server is frozen (restart it with the command
adb kill-server).
If none of the solutions help, try connecting the device to another computer. This will help determine whether the problem is in the PC or in the Android device itself.
6. ADB without root: what can be done without superuser rights
Many people mistakenly believe that ADB is useless without root access. In fact, even without superuser rights, you can perform dozens of useful actions:
Manage applications:
- ๐ฅ Install/remove APK (
adb install,adb uninstall). - ๐ View the list of installed packages (
adb shell pm list packages). - ๐ Stop/start applications (
adb shell am force-stop package name).
Work with files:
- ๐ Copy files from the device and back (
adb pull,adb push). - ๐๏ธ View the contents of folders (
adb shell ls /sdcard/).
Debugging and logs:
- ๐ View system logs (
adb logcat). - ๐ก Monitor CPU/memory usage (
adb shell top).
System commands:
- ๐ Reboot the device (
adb reboot). - ๐ถ Enable/disable Wi-Fi (
adb shell svc wifi enable/disable). - ๐ Adjust volume (
adb shell media volume --stream 3 --set 10).
Without root You cannot change system files (for example, in /system), but you can bypass some restrictions. For example, to access screenshots or screen recordings without notifications, use:
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
Restrictions without root:
- โ You cannot change system settings (for example,
build.prop). - โ You cannot access data from other applications (except your own).
- โ You cannot execute commands that require
su(for example,adb shell su).
7. ADB for non-developers: useful lifehacks
Even if you are not involved in development, ADB may be useful for everyday tasks. Here are some examples:
1. Speeding up your Android device
If your smartphone starts to slow down, you can manually clear the cache of all applications:
adb shell pm trim-caches 1G
Or forcefully stop unnecessary services:
adb shell am force-stop com.facebook.katana
2. Backup and recovery
Create a backup of all applications and data (without root):
adb backup -apk -obb -shared -all -f backup.ab
To restore:
adb restore backup.ab
3. Multimedia management
You can turn on/off music or video remotely:
adb shell input keyevent 85 # Pause/play
adb shell input keyevent 86 # Next track
4. Automation of actions
For example, unlock the device (if debugging is enabled and the PIN is known):
adb shell input text 1234 && adb shell input keyevent 66
Or take a screenshot and immediately send it to your PC:
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
5. Bypassing manufacturer restrictions
Some brands (for example, Huawei or Xiaomi) block the installation of APKs from unknown sources. Through ADB, this restriction is possible. bypass:
adb install -i com.android.vending -r app.apk
Flag -i com.android.vending simulates installation from Google Play.
โ ๏ธ Attention: Some commands (such as unlocking the screen or installing an APK) may violate your company's security policy if the device is used for business purposes. Please check your corporate policies before use.
8. Alternatives to ADB: when standard tools are not enough
If ADB doesn't do the job, consider these tools:
| Tool | For what you need | Link |
|---|---|---|
| Fastboot | Device firmware, bootloader unlocking | Included in platform-tools |
| Scrcpy | Remote device control from a PC (with screen transfer) | GitHub |
| Android Screen Monitor | Viewing the device screen in real time | Plugin for Android Studio |
| Termux | Terminal on the Android device itself (for commands without a PC) | Google Play |
When to use Fastboot instead of ADB:
- ๐ง For firmware
recovery(for example, TWRP). - ๐ To unlock the bootloader (
fastboot oem unlock). - ๐ฑ To flash the factory image (
fastboot flash system system.img).
Scrcpy vs ADB:
Scrcpy uses ADB to connect, but adds features:
- ๐ฅ๏ธ Transferring the device screen to a PC with minimal latency.
- ๐ฎ Keyboard/mouse control (as on an emulator).
- ๐น Recording the screen in high quality.
Launch example:
scrcpy --bit-rate 8M --max-size 1024
What is it for Termux:
If you do not have access to a PC, but need to execute ADB commands, install Termux and configure it adb:
pkg install android-tools
adb devices
This will allow you to manage the device directly from it (for example, make backups or monitor logs).
ADB is the basis, but for complex tasks (firmware, data recovery) you will need additional tools. Start with ADB and then master Fastboot i Scrcpy.
FAQ: Frequently asked questions about ADB in Android Studio
Can I use ADB on Mac or Linux?
Yes, ADB cross-platform. On macOS/Linux, install Platform-Tools in the same way as on Windows, and add the folder to PATH. The only difference is that for some commands you will need to put ./ before adb (For example, ./adb devices).
On Linux, you may need to configure rules udev for USB devices. Instructions are available on the official website.
How to find the serial number of the device if adb devices does not work?
If the device is not detected, try:
- Connect the device and run
lsusb(Linux/macOS) or check inDevice Manager(Windows). - The serial number is sometimes displayed in the phone settings:
Settings โ About phone โ Status โ Serial number. - On some devices, the serial number can be seen on the box or under the battery (if it is removable).
ADB works, but the commands give an error "Read-only file system" What should I do?
This error means that you are trying to change a system file without permissions root. Solutions:
- Gain
root-access (for example, through Magisk). - Use commands that do not require superuser rights (see section 6).
- If you need to change a system file, consider flashing a custom one
recovery(for example, TWRP).
Is it possible to recover deleted files via ADB?
Partially. If the files were recently deleted and their space on the disk is not overwritten, you can try:
- Connect via
adb shell. - Use
ls -lato search for temporary files (for example, in/data/local/tmp). - For deep scanning you will need
rootrights and tools like Autopsy or Scalpel.
Without root, the chances are minimal - ADB does not replace data recovery apps.
How to disable ADB if the device does not respond?
If after the commands adb device frozen:
- Disconnect the USB cable.
- Press the power button for 10-15 seconds to force a reboot.
- If the device does not respond, remove the battery (if possible) or wait until it is completely discharged.
To prevent such situations, avoid commands like adb shell reboot -p (instant shutdown) on unstable firmware.