24

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)

enter image description here

user924
  • 8,146
  • 7
  • 57
  • 139

8 Answers8

28

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
adb pair <ip-addr>:<port> <pairing_code>

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

  1. Make sure USB Debugging is enabled on the device you intend to connect with
  2. In your device, go to Developer Settings>Wireless Debugging and you will see something like so

Sample Screenshot

  1. Now carefully look at the IP ADDRESS AND PORT section and type the following in the terminal
  adb connect <ip-addr>:<port>

And your computer will show under paired devices like the above screenshot

gtxtreme
  • 1,830
  • 1
  • 13
  • 25
  • The second way does not work. I get "no route to host" and tcpip throws an error saying their are no devices. – John Glen Jun 05 '22 at 16:41
  • 3
    First way failed saying Unable to start pairing client – John Glen Jun 05 '22 at 16:42
  • 2
    "Make sure USB Debugging is enabled on the device you intend to connect with" is important ... even though you are using Wireless debugging, if USB debugging is not on, it just doesn't work. – Marc Durdin Jul 22 '22 at 01:55
  • Restarting the Android device fixed "Unable to start pairing" this issue for me – Cyph3rCod3r Jul 27 '22 at 07:12
  • Even worse, I get the following message in the terminal, "adb : The term 'adb' is not recognized as the name of a cmdlet, function, script file, or operable program." – EddieRich Jul 28 '23 at 13:16
27

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.

Android Wi-Fi Settings

Mike J
  • 416
  • 4
  • 6
4

I had the same problem but I managed to find the solution. You have to follow the following steps:

  1. In your smartphone (Go to Settings->Developer options-> Wireless Debugging->Pair device with pairing code).
  2. Copy the ipaddress & port. For example: 192.168.1.2:42123 and wifi pairing code: 234321.
  3. Open your terminal and go to the following path: cd %LOCALAPPDATA%/Android/sdk/platform-tools
  4. Paste the following command following this order: adb pair (ipaddress & port that you saw when you clicked on "Pair device with pairing code") abd pair 192.168.1.2:42123
  5. Paste the access code to the wifi connection. Enter pairing code: 41107.
  6. Finally, on the same screen go to the option that says IP address and port and you 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.

3

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

enter image description here

I don't know why there the issue with dynamic IPs

user924
  • 8,146
  • 7
  • 57
  • 139
3

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.

Hisham Hijjawi
  • 1,803
  • 2
  • 17
  • 27
1

This worked for me:

  • Tools --> Troubleshoot Device Connections
  • Press Next --> Next
  • Click 'Restart ADB server'
  • Freshly turn ON Wireless Debugging on device and wait for few seconds.
Shriram Panchal
  • 1,996
  • 1
  • 20
  • 23
1

This really helped me

Using Terminal Tool

type: adb pair {ip_address}:{port} {pairing_code}

Ahmed Saad
  • 13
  • 7
0

Important reminder and this is what solved my problem.

Devices must be on the same network.

Ronald Araújo
  • 1,395
  • 4
  • 19
  • 30