问题描述
是否可以在一台机器上编写代码/编译 Android 应用程序并在另一台机器上启动的模拟器上远程调试它?我厌倦了模拟器不断消耗笔记本电脑一半的 CPU.
Is it possible to write the code/compile Android application on one machine and debug it remotely on the emulator launched on another? I'm sick and tired of the emulator constantly eating half of my laptop's CPU.
推荐答案
我之前没有尝试过(甚至没有注意到)cmb 提到的 adb connect 命令,但我可以确认转发TCP 端口自己 -比如通过 SSH ——工作正常.
I haven't previously tried (or even noticed) the adb connect command that cmb mentioned, but I can confirm that forwarding the TCP ports yourself — such as over SSH — works fine.
模拟器在每个实例上侦听两个 TCP 端口:5554 用于 telnet 接口,5555 用于控制与 DDMS 等工具的通信.因此,您可能只需要转发端口 5555 就可以逃脱(尽管到目前为止我只尝试过两者).每个后续的模拟器都采用下一个可用的偶数+奇数端口号元组(我认为最多可达 5580 左右).
The emulator listens on two TCP ports per instance: 5554 for the telnet interface and 5555 for control communication with tools like DDMS. So you could probably get away with only forwarding port 5555 (though I've only tried it so far with both). Each subsequent emulator takes the next available even+odd port number tuple (up to around 5580, I think).
作为参考,我在本地机器上做了以下步骤:
For reference, I did the following steps on my local machine:
ssh -NL 5554:localhost:5554 -L 5555:localhost:5555 myuser@remote-serverkillall adb;adb 设备
我相信模拟器会在启动时尝试通知本地 adb 服务器;因此需要重新启动 adb 才能探测本地 5554+ 端口.
I believe the emulator tries to notify a local adb server at startup; hence the need to restart adb in order for it to probe the local 5554+ ports.
注意ssh命令中的localhost指的是remote机器的本地接口.
Note that the localhost in the ssh command refers to the local interface of the remote machine.
adb devices 展示了一个新的模拟器 —emulator-5554 —我可以像在本地机器上运行一样使用它.
adb devices showed a new emulator — emulator-5554 — and I could use it as if it were running on my local machine.
这篇关于使用 Android 模拟器进行远程调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)