Wi-Fi 调试 (ADB) - 设备配对时出错
当我第一次更新到新版本的 studio 时,我尝试使用这个新的 WiFi 调试功能,它第一次工作(使用二维码或手动输入代码),但现在它卡在 “连接到设备。这需要最多 2 分钟。”
消息持续一段时间,然后我收到 “设备配对时出错”
消息。之前需要几秒钟才能连接。我的设备是 Samsung S10 (12 Android)
更新:
在 Android 设备上使用真实 MAC 来连接当前 Wi-Fi 网络并不能真正解决问题:
Mb 在某些情况下会有所帮助,但是在我测试了一段时间后,它仍然有时无法连接,所以我必须在 Android 设备上手动打开无线调试屏幕并检查 ip:port 才能进入手动adb在终端中连接 ip:port
。
设备的 IP 永远不会改变。我在路由器设置中为所有设备设置了静态。这也没有帮助。
因此,目前这些解决方案都无法彻底解决问题。
我仍然需要在终端中调用以下命令:(
adb kill-server
net stop winnat
net start winnat
adb start-server
net * winnat
- 对于 Windows)
然后切换设备上的 Wi-Fi 以使其再次工作。
所以我还不能接受答案,尽管有些答案在某些情况下可能会有所帮助(但我们需要一个100%的解决方案)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
我通过禁用“隐私”下的“随机 MAC 地址”功能,在 Wi-Fi 设置中解决了该问题。使用我设备的实际 MAC 地址可以解决该问题。
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.
EDIT 3: A lot of people have reported that toggling Developer Settings work as well.Also ensure that you're not connected to the VPN, since tunneling is affected
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
我遇到了同样的问题,我所做的就是切换到与设备连接的命令行方式。您可以通过以下方式执行此操作
USB 调试
开发者设置>无线调试
,您将看到类似的东西IP 地址和端口
部分,然后在终端中键入以下内容,您的计算机将显示在已配对的设备下,如上面的屏幕截图
EDIT 3: A lot of people have reported that toggling Developer Settings work as well.Also ensure that you're not connected to the VPN, since tunneling is affected
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 am going to give you a age old solution
我遇到了同样的问题,但我设法找到了解决方案。
您必须按照以下步骤操作:
例如:192.168.1.2:42123
和 WiFi 配对代码:234321。
cd %LOCALAPPDATA%/Android/sdk/platform-tools
adbpair(您点击“使用配对代码配对设备”时看到的 IP 地址和端口)
adbpair 192.168.1.2:42123
输入配对代码:41107。
将看到相同的地址,但具有另一个端口(您可以在屏幕的这一部分找到它) ,复制并写入以下内容
命令:
adb connect 192.168.1.2:41107
如果您看到类似这样的消息“已连接到 192.168.1.2:41107”,那么您就做到了能够毫无问题地将您的手机与 android studio 连接。
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")
adb 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.
这确实对我
使用终端工具
配对有帮助:`
adbpair {ip_address}:{port} {pairing_code}
`
正在连接:`
adb connect {ip_address}:{port}
注意:
如果您的电脑已经配对,下次您可以使用连接步骤
This really helped me
Using Terminal Tool
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
请注意,当我使用 VPN 时,配对将无法进行。在关闭 VPN 的情况下进行配对后,我可以
adb connect ipaddress:port
并且成功了。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.我通过在路由器设置中手动为智能手机和 PC 分配 IP 地址来修复此问题。基本上避免了 DHCP。
重新启动了路由器。
清除旧配对。
再次开始配对,现在一直工作正常,无需重复配对过程,只需从通知面板启用“无线调试”,几秒钟后设备将在 Android Studio 中可用,
所以下次只需启用“无线调试” ” 已准备就绪
我不知道为什么会出现动态 IP 的问题
p.s.:虽然我不确定使用相同的 IP 地址是否真的可以修复它(需要对其进行测试以确保) ,所以暂时无法接受任何答案
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
这对我有用:
This worked for me:
在您的移动设备中启用USB调试选项,然后重试通过无线选项连接,它会起作用
在我的情况下它起作用了
enable the USB debugging option in your mobile device and then retry connecting through wireless option, It will work
In my case It worked
我最初也遇到此错误,但在重新启动设备后能够成功配对。
I initially got this error as well, but was able to successfully pair successfully after restarting the device.
对我有用的只是重新启动 adb 服务器。
What worked for me was simply restart the adb server.
尝试关闭开发者选项并再次打开。它就像一个魅力。快乐编码!
Try to turn off Developer Options and turn on again. It works like a charm. Happy coding!
您好,我是一名 ios/android 开发人员,使用 MacOS 进行 android wifi 调试,但总是有问题。
我几乎使用了上面所有的解决方案,例如,重新启动所有内容,撤销adb授权,adb终止服务器,有时有效,adb连接,adb配对,我有经验,所以我知道如何编写命令,我从未犯过错误,但它仍然停止工作。
所有解决方案和解决方法 - 对于 Mac
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
重要提醒,这就是解决我的问题的方法。
设备必须位于同一网络上。
Important reminder and this is what solved my problem.
Devices must be on the same network.