Starting debugging in the Android Studio development environment is a fundamental step for any programmer creating applications for the mobile platform. Without a correctly configured debugging process, it is impossible to effectively search for errors in the code, analyze the operation of the interface, or test the performance of the application on real devices. Many beginners encounter difficulties precisely at the stage of connecting a computer and a smartphone, when the development environment simply does not see the connected gadget.
The setup process includes several critical steps, starting from activating hidden menus on the phone itself and ending with installing specific drivers on the computer. In this article, we will look in detail at how to correctly initialize ADB (Android Debug Bridge), configure the emulator settings and fix the most common connection problems. Understanding these mechanisms will allow you to spend less time on technical problems and more time writing quality code.
It is worth noting that the procedure may vary slightly depending on the version of the operating system of your device and the manufacturer's model. However, the basic principle of interaction via the protocol ADB remains the same for all versions of Android, starting with the earliest releases. We will consider a universal algorithm of actions that is suitable for most development scenarios.
Activating developer mode on the device
The first and mandatory step is to unlock the hidden settings section, which is disabled by default for security reasons. On most modern smartphones running Android, you need to go to the main system settings and find the “About phone” or “About device” item. Here you should locate (find) the line “Build Number”.
To activate the mode, you will need to quickly click on this item seven times in a row. The system will count the clicks and issue a notification that you have become a developer. After this procedure, a new section called “For Developers” will appear in the main settings menu. This is where all the tools necessary to interact with the environment are concentrated Android Studio.
Inside this section you need to find the “USB Debugging” switch and activate it. When turned on for the first time, the system will issue a warning about potential security risks, since this mode provides deep access to the file system and processes of the device. Confirm the action by clicking "OK" in the pop-up dialog.
⚠️ Attention: Never leave USB debugging enabled in everyday use, especially when connecting to public charging stations. Attackers can use this open port to steal data or install malware without your knowledge.
It is also recommended in this menu to enable the “Keep the screen on” option when connecting the charger. This will prevent the device from locking up during long testing sessions when the screen needs to remain active to visually check the interface. Without this setting, the phone may go into sleep mode, breaking the connection with the debugger.
Setting up a connection via USB and drivers
After activating the software mode on the phone, you must ensure a physical and software connection to the computer. The quality of the cable plays a decisive role here: many cheap cables only support charging, but not data transfer. Use an original cable or a certified analogue that supports high-speed data transfer.
When you first connect the device to a computer with debugging enabled, a request to allow debugging from this computer will appear on the smartphone screen. You must check the box “Always allow from this computer” and confirm the action. Without this confirmation ADB will not be able to send commands to the device, and Android Studio will show the "Unauthorized" status.
Installing the correct drivers is critical for the Windows operating system. Unlike macOS and Linux, where drivers are often built into the kernel or installed automatically, manual installation may be required on Windows. They usually come with a package Google USB Driverthat can be downloaded through the SDK Manager inside Android Studio itself.
- 🔌 Use only USB 3.0 or higher ports to ensure stable data transfer speeds when deploying large applications.
- 🖥️ Check the Windows Device Manager: if the device shows up with a yellow exclamation point, the driver is not installed correctly.
- 🔄 Try different USB ports, as some motherboards may have problems with powering specific connectors.
If the automatic installation of drivers does not work, you can try selecting them manually from the list of compatible devices. Select the manufacturer (for example, Google or a specific vendor like Samsung) and protocol model ADB Interface. This often solves the problem when the computer sees the phone as a drive, but not as a debug device.
Using the Android Virtual Device emulator
It is not always possible or willing to connect a physical device. In such cases, the built-in emulator Android Virtual Device (AVD)comes to the rescue. It allows you to run a virtual copy of your smartphone directly on your computer, emulating different screen configurations, Android versions and amount of RAM.
To create an emulator, open AVD Manager through the Android Studio toolbar. Click the "Create Virtual Device" button, select the desired hardware configuration (for example, Pixel 5) and system image (System Image). It is recommended to select images marked Google APIsif your application uses Google Play services.
Running the emulator can require significant system resources, especially if hardware graphics acceleration is enabled. Make sure that virtualization technology (Intel VT-x or AMD-V) is enabled in your computer's BIOS. Without this, the emulator will work extremely slowly or will not start at all, giving an initialization error.
Why is the emulator slow?
If the emulator is running slowly, check whether enough RAM is allocated in the AVD settings. Also make sure that the antivirus does not scan system image files in real time, which can greatly slow down disk reading.
The advantage of the emulator is the ability to test on different versions of Android without having physical devices. You can quickly switch between Android 10, 11, 12 and later, checking the compatibility of your code. In addition, the emulator allows you to simulate various geolocations, battery levels and network connections.
Diagnostics of connection via ADB
Sometimes Android Studio does not see the device, even if all the settings are correct. In such cases, it is necessary to use the command line for direct diagnostics through the utility ADB. This utility is part of the platform Android SDK Platform-Tools and allows you to manage the device at a low level.
Open a terminal or command line and go to the folder with installed platform tools. Enter the command to check the list of connected devices. If everything is configured correctly, you will see your device's serial number and its status.
adb devices
The command output may contain multiple statuses. Status device means successful connection. The status unauthorized indicates that you have not verified the RSA key fingerprint on the phone screen. Status offline often indicates problems with drivers or an unstable connection.
| Status in ADB | Value | Action |
|---|---|---|
device |
The device is ready for use | You can start debugging |
unauthorized |
Confirmation on your phone is required | Check your smartphone screen |
offline |
Communication or driver failure | Reconnect the cable |
| list empty | Device not found | Check the cable and mode |
If the command adb kill-server seguida for adb start-server does not help restart the debugging daemon, try restarting the computer completely. Sometimes background processes can freeze, blocking access to USB ports for new connections.
☑️ Connection diagnostics
Wireless debugging via Wi-Fi
Starting with Android 11, it has become possible to debug without using a USB cable, which significantly frees up the workplace and allows you to test the application in more natural conditions of use. To do this, the device and computer must be on the same Wi-Fi network.
To enable this mode, go to the “For Developers” settings and find the “Wi-Fi Debugging” item. Activate it and click on the “Pair by code” option. The IP address, port and six-digit code will appear on the screen.
In Android Studio, go to menu Run → Pair Devices Using Wi-Fi. Enter the data from your phone screen. After successful pairing, the device will appear in the list of applications available for launch. This method is especially useful for testing gestures and movements that are difficult to reproduce with a cable connected.
⚠️ Attention: Wireless debugging consumes more power and may be unstable on networks with poor signal or high load. To debug heavy graphic scenes or work with large amounts of data, it is still recommended to use a wired connection.
It is worth considering that if the device’s IP address changes (for example, after reconnecting to the router), the connection may be lost. In this case, you will have to go through the pairing procedure again. Some corporate networks may block the ports needed for ADB, so a home network is often a better choice.
Solving common problems and errors
Even if you follow all the instructions, specific errors may occur related to the project configuration or equipment features. One common problem is the message “Installation failed with message Failed to establish session.” This is often due to lack of space on the device or an application version conflict.
Try clearing the application data on the device or completely deleting it before launching it again. Also check if the “Charge Only” mode is turned on in notifications when connecting a USB. Sometimes the system resets this setting after an update or reboot.
If you are using multiple devices at the same time, make sure that the specific target device is selected in the Run/Debug Configurations and not the “Choose automatically” option. This will prevent the application from accidentally launching on the wrong gadget.
If the application crashes immediately after launch, enable the Logcat logger in the bottom panel of Android Studio. Filter the logs by your application tag to see the exact cause of the crash (Exception).
In case of problems with the emulator, try creating a new virtual image with a different version of Android. Sometimes specific system images may be damaged or have bugs that prevent debugging tools from working correctly. Resetting the emulator data (Wipe Data) can also help in critical situations.
Why doesn’t Android Studio see my device?
The most common reasons: “Charge Only” mode is enabled, ADB drivers are not installed (for Windows), the cable is used only for charging, or the RSA key request on the phone screen is not confirmed. Check the command output adb devices for an accurate diagnosis.
How to disable USB debugging?
Go to the phone settings, open the “For Developers” section and turn the “USB Debugging” switch to the “Off” position. To completely hide the developer menu, you can clear the Settings application data in the application menu.
Is it possible to debug the app on Android TV?
Yes, the principle is the same. Enable USB debugging in the TV settings (usually in the “About device” → “Build” section). Connect it to PC and use ADB. For a wireless connection, you often need to know the static IP of the TV.
What to do if the emulator starts with a black screen?
Try changing the graphics settings in the AVD configuration to “Software - GLES 2.0”. Also make sure you have the latest updates to your video card's video drivers and have virtualization enabled in the BIOS.
Is it safe to leave debugging enabled?
No, it reduces the security of the device. If the phone is stolen or lost, an attacker with access to the computer can gain full control of the data. Always disable this feature when you're done.