In this post i will explain you how to enable wireless debugging for Android development. Previously we were using USB debugging for real devices during our Android app development and we did have option to switch to wireless debugging mode. But the problem with this approach was, as every one who tried this method already knows that, it requires you to connect your real device to the machine through USB port and only after that we are able to switch to wireless port in the ADB tool for enabling wireless debugging.
This is not a preferred way by many developers because, wireless debugging should not depend on USB. Today developers are on machines which don’t have physical USB ports so the alternative option for debugging which is wireless debugging it requires USB port connectivity first. So this is a conflict.
Today for the versions Android 11+ we have this issue fixed completely and we don’t need USB port access or connectivity to the device. This ADB feature enables us to connect our development device to connect to the Android Studio through ADB tool over WI-FI.
Following are the steps need to do to enable wireless debugging for devices running android version 11+/ Android R.
Step 1. Enable Developer options
By default, Developer options menu is hidden in all Android devices. To show Developer options,
- Go to Settings > About Phone > Build number
Tap on Build Number 7 times, then you will see a message saying “Developer mode has been enabled”. Now you can go back to the settings page and find out the Developer options. Developer options usually located at the bottom of the settings page.
Above is the screenshot of Samsung’s Developer options settings page.
Once you enabled it, you are ready to go.
Open ADB In Command Line Tool
ADB is Android device bridge tool, which helps us to connect android devices to Android studio. Open adb tool in command line of the development computer. For opening it, we have to find the location of the adb. If you know the SDK folder path, then please go to the following location,
- Go to SDK folder > platform-tools
Start command line terminal from this platform-tools folder. Please make sure adb file is present under this folder. Once you are good to go then,
Please run the following adb command in the terminal of the computer.
adb devices
This is a test command, and it will list down all the connected devices through ADB. If everything is working correctly then you will be able to see empty device list.
If you are getting error saying, “command not found adb”, then this error indicates that you have not properly set adb path to your computer’s PATH variable. To fix this error, you have to set PATH variable and assign platform-tools folder’s path to PATH variable.
If all the above steps completed successfully then, we are good to go to the next step.
Step 2. Enable Wireless Debugging
Our next step is to enabling wireless debug option in the Android device. For this, let’s connect our Android device to the Wi-Fi network.
Please make sure you have connected the development computer and Android device to the same Wi-Fi network.
- Go to developer options > wireless debugging
If you are in a long list of developer options and hard to find it then please use search box in settings.
Please switch on “Wireless debugging”. You will now see Pairing options in the page.
Step 3. Pair Android Device
Click on pair device with pairing code. This will open up a popup window with information required to pair like IP address, port and pairing code.
Above is the information required to pair our Android device with Android studio over Wi-Fi.
Now please go back to ADB command line window and hit the following command.
adb pair <ip address>:<port number>
eg: adb pair 192.168.1.130:37099 (please don't copy this)
Hitting the above command will prompt you for the pairing code. Please enter the pairing code from the pairing popup showing in your device.
If the Android device connected to Android Studio IDE correctly over Wi-Fi then you will see the following messages as the response of the command in the command line window.
none Enter pairing code: 482924 Successfully paired to 192.168.1.130:37099 [guid=adb-
Check Connected Android Device In Android Studio Logcat Window
Finally, you will be able to see your connected device in the list of Android studio logcat window’s device list dropdown as an active debug device.
Now you can start the debugging over Wi-Fi without any physical connectivity between computer and Android device. You can turn off the wireless debugging from the device’s status bar when you want to disconnect it from the IDE.
Happy Coding!
Reference: https://developer.android.com/studio/command-line/adb