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

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

问题描述

我想访问来自Android模拟器提供的一台机器上我的局域网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.

但它在另一台计算机局域网上运行。我想我可以另外添加其他重定向主机上与上述的(本来虽然使用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)。

在我的测试之前读过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.

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

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