When I first update to new version of studio I tried to use this new WiFi debug feature and it was working at first time (using QR code or manually typing the code) but now it’s stuck with "Connecting to device. This takes up to 2 minutes."
message for some time and then I get "There was an error pairing the device"
message. Before it would take a couple of seconds to connect. My device is Samsung S10 (12 Android)
The official documentation can be found here.
7
Answers
I fixed it by manually assigning IP addresses for my smartphone and PC at settings of the router. Basically avoiding DHCP.
Restarted the router.
Cleared old pairing.
Started pairing again and now it works fine all the time, and no need to repeat pairing process, just enabling "Wireless debugging" from notification panel and in couple of seconds the device will be available in Android Studio
So next time just enable "Wireless debugging" and it's ready
I don't know why there the issue with dynamic IPs
EDIT 2: Take a look at the below answers, the actual reason seems to be that the device is assigned a random IP or a MAC via DHCP, if you can disable that via system settings for your specific custom ROM, then it’s even better
EDIT: If you see regular disconnections, click on `Pair Device with Pairing Code`, and then pair your device with the following command
I was facing the same issue, what I did was switching to the command line way of connecting with the device. You can do so in the following way
USB Debugging
is enabled on the device you intend to connect withDeveloper Settings>Wireless Debugging
and you will see something like soIP ADDRESS AND PORT
section and type the following in the terminalAnd your computer will show under paired devices like the above screenshot
I was able to resolve the issue from within Wi-Fi settings by disabling the Randomized MAC Address feature under Privacy. Using my device’s actual MAC address fixes the issue.
This worked for me:
I had the same problem but I managed to find the solution.
You have to follow the following steps:
For example: 192.168.1.2:42123
and wifi pairing code: 234321.
cd %LOCALAPPDATA%/Android/sdk/platform-tools
adb pair (ipaddress & port that you saw when you clicked on "Pair device with pairing code")
abd pair 192.168.1.2:42123
Enter pairing code: 41107.
will see the same address but with another port (You can find it in this part of your screen), copy it and write the following
command:
adb connect 192.168.1.2:41107
If you see a message like this "connected to 192.168.1.2:41107", you did it you will be able to connect your phone with android studio without any problem.
Note that for me pairing wouldn’t work while I was on my VPN. After I paired while off the VPN, I could
adb connect ipaddress:port
and it worked.Important reminder and this is what solved my problem.
Devices must be on the same network.