简体   繁体   English

使用手机连接本地机器在远程桌面Android Studio上开发

[英]Use phone connected to local machine to develop on remote desktop Android Studio

I work on Windows Remote Desktop.我在 Windows 远程桌面上工作。 Local and remote OS are Windows 10. I need to access my android phone connected to my laptop via USB in Android Studio which is running on the remote desktop to build app directly on my phone. Local and remote OS are Windows 10. I need to access my android phone connected to my laptop via USB in Android Studio which is running on the remote desktop to build app directly on my phone. My phone is visible in the Remote Desktop Connection configuration "Local devices and resources" list and is checked in, but adb doesn't see the device on the remote desktop.我的手机在远程桌面连接配置“本地设备和资源”列表中可见并已签入,但 adb 在远程桌面上看不到该设备。 (Even the remote dekstop OS doesn't see it) (即使是远程桌面操作系统也看不到它)

It's a bit tricky but adb have the power to connect any network-reachable device on the globe with the correct configuration.这有点棘手,但 adb 有能力以正确的配置连接全球任何可通过网络访问的设备

No need for USB, just connect device to the local WiFi.无需USB,只需将设备连接到本地WiFi即可。

The action involves port forwarding on your home router.该操作涉及家庭路由器上的端口转发。 You need to do 2 things:你需要做两件事:

  1. Pair device - only 1 time but the device will un-pair itself if not connected to adb for a while.配对设备 - 仅 1 次,但如果一段时间未连接到 adb,设备将自行取消配对。
  2. Connect device - each time you plug your device连接设备 - 每次插入设备时

Pairing instructions (Android 11 or above):配对说明(Android 11 或以上):

  1. Extract your home network's external IP, let's call it HOME_IP .提取您家庭网络的外部 IP,我们称之为HOME_IP
  2. Turn on wireless debugging from developer options.从开发者选项打开无线调试。
  3. In wireless debugging screen, choose to pair with code - the IP of your device and some port will show up (along with 6-digit code), let's name those DEVICE_IP and PAIRING_PORT respectively.在无线调试屏幕中,选择与代码配对 - 您设备的 IP 和一些端口将显示(以及 6 位代码),我们分别命名为DEVICE_IPPAIRING_PORT
  4. Add the following port forwarding rule to your router: protocol TCP, external & internal ports PAIRING_PORT , ip DEVICE_IP .将以下端口转发规则添加到您的路由器:协议 TCP、外部和内部端口PAIRING_PORT 、 ip DEVICE_IP
  5. In the remote OS, execute (without <> chars) adb pair <HOME_IP>:<PAIRING_PORT> , then enter the 6-digits code from device.在远程操作系统中,执行(不带 <> 字符) adb pair <HOME_IP>:<PAIRING_PORT> ,然后从设备输入 6 位代码。

Note that step 3 is with timeout so prepare your router settings screen and remote OS's cmd before step 3.请注意,第 3 步是超时,因此请在第 3 步之前准备好您的路由器设置屏幕和远程操作系统的 cmd。

Connecting instructions:连接说明:

  1. After successful pairing, in wireless debugging screen, an ip and port will show up, let's call those DEVICE_IP and CONNECTION_PORT respectively.配对成功后,在无线调试界面会出现一个ip和端口,我们分别称它们为DEVICE_IPCONNECTION_PORT
  2. Add the following port forwarding rule to your router: protocol TCP, external & internal ports CONNECTION_PORT , ip DEVICE_IP .将以下端口转发规则添加到您的路由器:协议 TCP、外部和内部端口CONNECTION_PORT 、 ip DEVICE_IP
  3. In the remote OS, execute (without <> chars) adb connect <HOME_IP>:<CONNECTION_PORT> .在远程操作系统中,执行(不带 <> 字符) adb connect <HOME_IP>:<CONNECTION_PORT>

Assuming the remote desktop is at your office - make sure your requests passes corporate firewall.假设远程桌面在您的办公室 - 确保您的请求通过公司防火墙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在云端开发,但通过远程桌面通过USB在本地设备上调试Android应用程序 - Develop in the cloud, but Debug Android App on local device over USB over Remote Desktop 为什么 VirtualBox 中的 Android Studio 无法使用它所连接的手机? - Why is Android Studio in VirtualBox unable to use a phone it is connected to? 为Windows或Linux系统开发远程桌面连接android应用 - Develop remote desktop connect android app for windows or linux system 获取Android Studio以使用本地Javadoc代替远程 - Get Android Studio to use local javadoc instead of remote Android工作室慢于远程桌面 - Android studio slow over remote desktop Android在虚拟机上开发 - Android develop on virtual machine 如何访问连接到远程计算机的Android设备的Chrome开发者工具? - How to access chrome developer tools for an android device connected to a remote machine? 如何通过使用模拟器或通过USB连接的设备(例如Android Studio)的android应用程序将文件写入桌面? - How to write files to your desktop with the use of an android application using an emulator or USB-connected device using for example Android Studio? Android Studio-一旦手机以恒定的logcat流连接,调试就会开始 - Android Studio - Debugging starts as soon as phone is connected with constant logcat stream Mac 上的 Android Studio 无法检测到已连接的 USB 手机 - Android studio on Mac cannot detect connected USB phone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM