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.
这篇关于有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?


基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01