Is there an easy way to setup the android emulator to access the LAN of the host machine?(有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?)
问题描述
我想从 android 模拟器访问由我的 LAN 上的一台机器提供的 Web 服务.
I would like to access a web service provided by one of the machines on my LAN from the android emulator.
如果服务在运行模拟器的同一台机器(称为主机)上运行,我可以添加网络重定向并使用正确的端口访问 10.0.2.2(模拟器中的主机环回接口).
If the service was running on the same machine where the emulator is running (called host), I could add a network redirection and access the 10.0.2.2 (host loopback interface in the emulator) with the correct port.
但是它正在 LAN 上的另一台机器上运行.我想我可以在主机上添加另一个重定向到上述重定向(尽管必须与 iptables 斗争......),但是否存在更简单的解决方案?
However it is running on another machine on the LAN. I guess I could add another redirection on the host additionally to the above one (would have to fight with iptables though ... ), but does a more simple solution exist ?
推荐答案
好吧,它只是工作(TM).
Well, it just works (TM).
在我在测试之前阅读的android模拟器手册中(我在做事之前尝试使用RTFM)是这样说的:
In the android emulator manual that I had read before testing (I try to RTFM before doing things) this is stated:
模拟器的每个实例都在虚拟路由器/防火墙服务后面运行,该服务将其与您的开发机器的网络接口和设置以及互联网隔离开来.仿真设备看不到您的开发机器或网络上的其他仿真器实例.相反,它只看到它通过以太网连接到路由器/防火墙.
Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet to a router/firewall.
这让我觉得它无法访问我的局域网.我错了,只需在我的局域网上添加服务器的 IP 就可以从模拟器访问它.
This made me think that it could not access my LAN. I was wrong, just adding the IP of the server on my LAN allowed me to access it from the emulator.
这篇关于有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01