【问题标题】:Can Visual Studio connected to adb server on other computer run android devices connected to the other computer?连接到其他计算机上的 adb 服务器的 Visual Studio 可以运行连接到其他计算机的 android 设备吗?
【发布时间】:2025-12-17 04:25:02
【问题描述】:

我的设置:

我有带有 android 工具的 mac。还有一个 Windows 虚拟机 - 不幸的是 can't run android directly。所以我按照本指南连接了它们:https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/connect-android-emulator-mac-windows,它们在同一个 vpn 上。

我可以看到模拟器在我的 mac 上启动并从 windows 机器上成功运行我的 xamarin 应用程序:

但是,当将 android 设备连接到 mac 时,它不会出现在 windows 机器上的 Visual Studio 中。在我的 Mac 上运行 adb devices 会显示:

而且我可以从我在我的 mac 上安装的其他框架成功地在其上运行应用程序。

有什么方法可以让 Visual Studio 通过 adb 服务器找到 android 设备?

【问题讨论】:

标签: visual-studio azure xamarin android-emulator adb


【解决方案1】:

我认为如果您使用 ADB over network,您的运气会更好。

在您连接了可以运行的设备的计算机上:

adb tcpip 5555

然后,如果您知道设备的 IP,您可以从同一网络上的任何计算机连接:

adb connect ip:5555

那么它应该会出现在VS的设备列表中。

【讨论】:

  • adb connect 永远不会结束。我不是 tcpip 所做的 100%,但请注意 mac 和虚拟 Windows 机器在同一个 vpn 上。我认为设备也必须在同一个 vpn 上才能通过它的 IP 地址连接它?
  • 设备需要与您使用 VPN 软件连接的同一网络。
  • 我是一个 azure vpn。我同时连接了mac和虚拟Windows机器。我不认为我可以将移动设备连接到它。它使用带有加密功能的 IKEv2。
  • 是的,换一种方式,从 VM 到 mac 和设备所在的网络会容易得多。
  • 只是我必须进入路由器设置才能打开我相信的端口。这有点不安全。而且我还希望能够在我想要的地方工作。