android - Android 模拟器之间的通信

标签 android android-emulator

我想知道是否有可能在两台联网的不同机器上启动两个 Android 模拟器之间的通信。

例如 - 模拟器 A 在机器 M1 上运行 - 模拟器 B 在机器 M2 上运行

A 和 B 可以交换消息吗?

如果是,我使用什么 IP 地址?

非常感谢 黛博拉

最佳答案

您可能已经知道这一点。从 android-sdk-tools_r7 开始,至少应该可以将两个模拟器相互连接。我不知道它是否在物理机器之间工作。可以为此特定广播在两个主机之间设置伪装。

来自安卓commit

Enable interconnection of emulators

This patch adds a -shared-net-id option to the emulator which joins the emulator in a shared network. If the option is given the emulator is started with an additional network interface bound to a multicast socket. This multicast socket emulates a network hub, interconnecting emulators. If the -shared-net-id option is not given, nothing changes.

要连接两个模拟器,请使用 -shared-net-id <number>启动模拟器时的命令行选项。然后他们将直接共享发送到 ip 10.1.2.<number> 或从 ip 读取的所有内容在模拟器上。

另一种方法是使用 adb 在模拟器之间启用端口转发,然后在联网机器上为这些端口设置伪装。

我不太确定这些解决方案中的任何一个是否符合您所要求的用例。如果没有,向原始问题添加更多详细信息可能会有所帮助。 :)

免责声明:我没有尝试过第一种方法,而第二种方法我只是用来确保模拟器可以绕过讨厌的公司防火墙和 HTTP 代理,以便我们可以测试 android 浏览器。不过这个原则应该是合理的。

更新: 不,我玩了很多,没有找到很好的解决方案。我的 iptables 不够好,无法以这种方式设置适用于服务器端的有效隧道。

问候,
迈克尔

关于android - Android 模拟器之间的通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4044479/

相关文章:

android - 当我尝试实现滚动条时,我的应用程序崩溃了

python - Android的MonkeyRunner偶尔会抛出异常

java - android webview显示空白页面

android - Apk 扩展文件未通过模拟器下载

windows - Android 模拟器不刷新其显示

android - 我的 Android 虚拟设备出了什么问题?

java - Pipe ("|")和 grep 在 Android 中的 ProcessBuilder 中不起作用

android - 在 Horizo​​ntalGridView Android 中设置列​​数和水平

java - 在Gradle文件中使用名称有问题的.so库

android - 在 Android 上的 NDK 库中使用 Clang 地址清理程序