Wi-Fi 调试 (ADB) - 设备配对时出错

发布于 2025-01-09 11:28:51 字数 997 浏览 1 评论 0原文

当我第一次更新到新版本的 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)

enter image description here

Update:

Using real MAC for the current Wi-Fi network on Android devices doesn't really solves the issue:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

独留℉清风醉 2025-01-16 11:28:51

我通过禁用“隐私”下的“随机 MAC 地址”功能,在 Wi-Fi 设置中解决了该问题。使用我设备的实际 MAC 地址可以解决该问题。

Android Wi- Fi 设置

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

辞慾 2025-01-16 11:28:51

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

adb pair <ip-addr>:<port> <pairing_code>

我遇到了同样的问题,我所做的就是切换到与设备连接的命令行方式。您可以通过以下方式执行此操作

  1. 确保您要连接的设备上启用了 USB 调试
  2. 在您的设备中,转到开发者设置>无线调试,您将看到类似的东西

Sample Screenshot

  1. 现在仔细查看 IP 地址和端口 部分,然后在终端中键入以下内容
  adb connect <ip-addr>:<port>

,您的计算机将显示在已配对的设备下,如上面的屏幕截图


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

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

蓝眼睛不忧郁 2025-01-16 11:28:51

我将为您提供一个古老的解决方案

  1. 关闭开发人员选项
  2. 打开开发人员选项
  3. 打开 USB 调试
  4. 打开无线调试
  5. 尝试使用二维码连接
  6. 当您看到关闭并打开此选项仍然是许多复杂问题的解决方案时,请感到高兴问题

I am going to give you a age old solution

  1. Turn off Developer Options
  2. Turn On Developer Options
  3. Turn on USB Debugging
  4. Turn On Wireless Debugging
  5. Try to connect with QR Code
  6. Be Happy when you see that turning this off and on still is a solution to many complex problems
失眠症患者 2025-01-16 11:28:51

我遇到了同样的问题,但我设法找到了解决方案。
您必须按照以下步骤操作:

  1. 在您的智能手机中(转到“设置”->“开发者选项”->“无线调试”->“使用配对代码对设备进行配对”)。
  2. 复制ip地址和港口。
    例如:192.168.1.2:42123
    和 WiFi 配对代码:234321
  3. 打开终端并转到以下路径:
    cd %LOCALAPPDATA%/Android/sdk/platform-tools
  4. 按照以下顺序粘贴以下命令:
    adbpair(您点击“使用配对代码配对设备”时看到的 IP 地址和端口)
    adbpair 192.168.1.2:42123
  5. 将访问代码粘贴到 WiFi 连接。
    输入配对代码:41107。
  6. 最后,在同一屏幕上,转到显示 IP 地址和端口以及您的选项
    将看到相同的地址,但具有另一个端口(您可以在屏幕的这一部分找到它) ,复制并写入以下内容
    命令:
    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:

  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")
    adb 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.

快乐很简单 2025-01-16 11:28:51

这确实对我

使用终端工具

配对有帮助:`

  1. 启用无线调试
  2. 点击使用配对代码对设备进行配对
  3. strong>终端类型:adbpair {ip_address}:{port} {pairing_code}
  4. 您将在配对设备名称 >
    `

正在连接:`

  1. 注意上面将设备与二维码配对中找到的ip端口[非常重要
  2. ] >terminal 输入:adb connect {ip_address}:{port}
  3. 您将在您的电脑名称下方看到当前已连接,恭喜: )

注意
如果您的电脑已经配对,下次您可以使用连接步骤

This really helped me

Using Terminal Tool

Pairing: `

  1. enable wireless debugging
  2. click on Pair device with pairing code
  3. in terminal type: adb pair {ip_address}:{port} {pairing_code}
  4. you will see your pc name below Paired devices
    `

Connecting: `

  1. Note ip and port found above Pair device with QR code [VERY IMPORTANT]
  2. in terminal type: adb connect {ip_address}:{port}
  3. you will see Currently connected below your pc name ,congrats :)

Note:
next time you can use Connecting step if your pc already paired

欲拥i 2025-01-16 11:28:51

请注意,当我使用 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.

信愁 2025-01-16 11:28:51

我通过在路由器设置中手动为智能手机和 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

enter image description here

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

_失温 2025-01-16 11:28:51

这对我有用:

  • 工具 -->排除设备连接故障
  • 按下一步 -->接下来
  • 单击“重新启动 ADB 服务器”,
  • 在设备上重新打开无线调试并等待几秒钟。

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.
假面具 2025-01-16 11:28:51

在您的移动设备中启用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

听,心雨的声音 2025-01-16 11:28:51

我最初也遇到此错误,但在重新启动设备后能够成功配对。

I initially got this error as well, but was able to successfully pair successfully after restarting the device.

絕版丫頭 2025-01-16 11:28:51
  • 关闭开发者选项,然后再次打开。
  • 打开USB调试。
  • 打开无线调试。
  • 问题就解决了。
  • Turn off developer options, then turn them on again.
  • Turn on usb debugging.
  • Turn on wireless debugging.
  • And the problem is solved.
面如桃花 2025-01-16 11:28:51

对我有用的只是重新启动 adb 服务器。

adb kill-server

adb start-server

What worked for me was simply restart the adb server.

adb kill-server

adb start-server
小伙你站住 2025-01-16 11:28:51

尝试关闭开发者选项并再次打开。它就像一个魅力。快乐编码!

Try to turn off Developer Options and turn on again. It works like a charm. Happy coding!

呢古 2025-01-16 11:28:51

您好,我是一名 ios/android 开发人员,使用 MacOS 进行 android wifi 调试,但总是有问题。

我几乎使用了上面所有的解决方案,例如,重新启动所有内容,撤销adb授权,adb终止服务器,有时有效,adb连接,adb配对,我有经验,所以我知道如何编写命令,我从未犯过错误,但它仍然停止工作。

所有解决方案和解决方法 - 对于 Mac

  1. 我的解决方案是重新启用应用程序 Android Studio 来访问本地网络 - 为此,请转到“设置”->“隐私和隐私”。安全 -> 本地网络 - 然后禁用 android studio,然后重新启用它 - 然后重新启动 androd studio,它检测到所有配对的设备,
  2. 请注意应禁用“随机 MAC 地址”,如果选项不可用,则应使用“设备 Mac”,忘记 Android 设备上的网络并重新添加 wifi 网络并更改随机 MAC 地址
  3. ./adb connect 和 ./adbpair 如果它们可以工作则没有用,那么 Android studio 连接对话框也将工作,所以不是很有用,当 android工作室连接对话框不起作用,这些命令也不起作用,我
  4. 在 wifi 网络连接设置中尝试了很多禁用 - 限制 IP 跟踪(如有必要)

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

  1. My solution was to re enable the app Android Studio to access Local Networks - for this goto Settings->Privacy & Security->Local Network - then disable android studio and then re enable it - then restart androd studio, it detected all paired devices
  2. note the "Randomized MAC Address" should be disabled, you should use "Device Mac" if option not available, forget the network on android device and re-add wifi network and change the Randomized MAC Address
  3. ./adb connect and ./adb pair are useless if they will work then the Android studio connect dialog will work too, so not really useful, when android studio connect dialog doesn't work, these commands will also not work, i tried a lot
  4. disable in wifi network connection settings - Limit IP tracking, if necessary
最好是你 2025-01-16 11:28:51

重要提醒,这就是解决我的问题的方法。

设备必须位于同一网络上。

Important reminder and this is what solved my problem.

Devices must be on the same network.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文