Reputation: 12145
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)
Update:
Using real MAC for the current Wi-Fi network on Android devices doesn't really solves the issue:
Mb it helps in some cases, but after I tested it for a while it still can't connect from time to time so I have to manually open Wireless Debug screen on a Android device and check ip:port to enter manually adb connect ip:port
in Terminal.
IPs of devices never change. I set static for all devices in router's settings. It also doesn't help.
So for now none of these solutions solves the issue for good.
I still have to call the following in Terminal:
adb kill-server
net stop winnat
net start winnat
adb start-server
(net * winnat
- For windows)
Then switch Wi-Fi on the device to make it work again.
So I can't accept the answer yet, though some answers may help in some cases (but we need a 100% solution)
Upvotes: 49
Views: 47154
Reputation: 4044
I have written a script below for quickly connecting using adb pair
and adb connect
on Mac: https://gist.github.com/bartwell/05cb8f4e2a913229ea652fe1eed956e7
Usage:
./script.sh 192.168.0.101
./script.sh 192.168.0.101 --restart-server
./script.sh -h
Upvotes: 0
Reputation: 1976
Hi i am a ios/android developer and use MacOS for android wifi debugging and it was always problematic.
I almost used all the solutions above like, restart everything, revoke adb authorizations, adb kill-server, sometimes worked, adb connect, adb pair, i have experience so i know how to write commands, i never made mistake still it stopped working.
All solutions and work arounds - for Mac
Edit: All steps line wise, first install an app named LocalSend on both mac and android phone (its a free opensource app to transfer data between android/mac)
These steps i have worked with from a long time in macos 15.2 currently - works all the time 100% Look at the things we do as a developer haha!
Note: Installing LocalSend is not mandatory, its optional, just to check if you device is detected on mac, and once the device is detected by mac, we can use adb connect ... or we follow other solutions like disabling/enabling wifi debugging or in last disabling/enabling USB debugging, in my mac sometimes it doesn't even detect the device in LocalSend or other sharing apps, so other solutions of reseting adb/usbdebugging doesn't work, so first i make sure that the sharing apps detect my device and then follow other solutions related to android instead of wifi connection
Upvotes: 0
Reputation: 21
Try to turn off Developer Options and turn on again. It works like a charm. Happy coding!
Upvotes: 0
Reputation: 5704
What worked for me was simply restart the adb server.
adb kill-server
adb start-server
Upvotes: 1
Reputation: 99
Upvotes: 0
Reputation: 3566
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
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 terminal adb connect <ip-addr>:<port>
And your computer will show under paired devices like the above screenshot
Upvotes: 50
Reputation: 2310
I am going to give you a age old solution
Upvotes: 14
Reputation: 12145
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
p.s.: though I'm not sure if using the same IP address really fixes it (need to test it for sure), so can't accept any answer for now
Upvotes: 3
Reputation: 2277
I initially got this error as well, but was able to successfully pair successfully after restarting the device.
Upvotes: 0
Reputation: 101
I had the same problem but I managed to find the solution. You have to follow the following steps:
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.
Upvotes: 10
Reputation: 175
This really helped me
Pairing: `
adb pair {ip_address}:{port} {pairing_code}
Connecting: `
adb connect {ip_address}:{port}
Note: next time you can use Connecting step if your pc already paired
Upvotes: 5
Reputation: 1
enable the USB debugging option in your mobile device and then retry connecting through wireless option, It will work
In my case It worked
Upvotes: 0
Reputation: 1479
Important reminder and this is what solved my problem.
Devices must be on the same network.
Upvotes: -2
Reputation: 2415
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.
Upvotes: 3
Reputation: 2086
This worked for me:
Upvotes: 2
Reputation: 806
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.
Upvotes: 66