有没有一种简单的方法来设置安卓模拟器来访问主机的局域网? [英] Is there an easy way to setup the android emulator to access the LAN of the host machine?

查看:67
本文介绍了有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 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.

这篇关于有没有一种简单的方法来设置安卓模拟器来访问主机的局域网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆