如何从 Genymotion android 模拟器访问本地主机?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20257266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to access localhost from a Genymotion android emulator?
提问by mownier
I can not figure out how to access localhost from a Genymotion android emulator. By the way, Im using MAMP.
我不知道如何从 Genymotion android 模拟器访问 localhost。顺便说一句,我使用 MAMP。
回答by Coderji
Update
更新
After genymotion update to 2.2 you can use 10.0.3.2
, ref
genymotion 更新到 2.2 后,您可以使用10.0.3.2
,参考
Another approach
另一种方法
To access your localhost through Genymotion is using your PC IP address. to get your IP address go to:
通过 Genymotion 访问您的本地主机是使用您的 PC IP 地址。要获取您的 IP 地址,请访问:
start -> cmd -> ipconfig
then search for IPv4, copy the IP and paste it in your URL. It should looks like the following:
然后搜索 IPv4,复制 IP 并将其粘贴到您的 URL 中。它应该如下所示:
String YourURL = "http://192.168.0.106:8888/your_script_location.php";
Hope this works too for you, give me a feedback.
希望这对你也有用,给我一个反馈。
P.S: if it didn't work, turn off the firewall and any anti-virus application you have in your PC.
PS:如果它不起作用,请关闭防火墙和PC中的任何防病毒应用程序。
回答by David Hackro
you need this structure
你需要这个结构
Genymotion
基因运动
Default AVD
默认AVD
the http it's very important and the port it's for default It depends on your server.
http 非常重要,默认端口取决于您的服务器。
you can check this url in your browser the smartphone
您可以在智能手机的浏览器中查看此网址
回答by Sydney
The IP returned by ipconfig
dit not work for me. However 10.0.3.2
worked for me even though the IP address in the Wifi setting is 10.0.3.15
.
ipconfig
di返回的 IP对我不起作用。但是10.0.3.2
对我有用,即使 Wifi 设置中的 IP 地址是10.0.3.15
.
Genymotion 2.2.0
Genymotion 2.2.0
回答by ikuchris
it works for me by using http://192.168.56.1:8080
它通过使用对我有用 http://192.168.56.1:8080
to know your IP just use the following command
要知道您的 IP 只需使用以下命令
- for
(mac and linux)
ifconfig vboxnet0
- windows command
ipconfig vboxnet0
- 对于(mac 和 linux)
ifconfig vboxnet0
- 窗口命令
ipconfig vboxnet0
and make sure the port is collect.
并确保端口是收集的。
I got the answer from : here
回答by Madan Sapkota
Genymotion! It works for me using IP 10.0.3.2but depends on your localhost port. Apache it will be just IP and Tomcat with default port 8080. Here I take screenshots.
Genymotion!它使用 IP 对我有用,10.0.3.2但取决于您的本地主机端口。Apache 它将只是具有默认端口的 IP 和 Tomcat 8080。这里我截图。
1. Apache Screenshot
1. Apache 截图
2. Tomcat Screenshot
2. Tomcat 截图
Hope this is helpful. Thanks!
希望这是有帮助的。谢谢!
回答by Ghosthack
Intro:
介绍:
Long story short, Genymotion is running on Virtualbox, and the default network configuration is “Host-Only.” This method essentially emulates a physical network that is shared by your Genymotion VM (the emulator) and your host machine. The name of the network is vboxnet0, and if you run “ifconfig vboxnet0” (or “ipconfig vboxnet0” if running Windows) on your host machine, you should receive the IP address of your host on the vboxnet0 network. The default IP is most likely 192.168.56.1.
长话短说,Genymotion 在 Virtualbox 上运行,默认网络配置是“Host-Only”。此方法实质上模拟了由您的 Genymotion VM(模拟器)和您的主机共享的物理网络。网络的名称是 vboxnet0,如果您在主机上运行“ifconfig vboxnet0”(或“ipconfig vboxnet0”,如果运行 Windows),您应该在 vboxnet0 网络上收到主机的 IP 地址。默认 IP 很可能是 192.168.56.1。
Solution:
解决方案:
This is the IP address to use when accessing your host machine from the Genymotion emulator. For my Rails app, this meant calling “192.168.56.1:3000” instead of “10.0.2.2:3000.”
这是从 Genymotion 模拟器访问主机时要使用的 IP 地址。对于我的 Rails 应用程序,这意味着调用“192.168.56.1:3000”而不是“10.0.2.2:3000”。
Link:
关联:
http://bbowden.tumblr.com/post/58650831283/accessing-a-localhost-server-from-the-genymotion
http://bbowden.tumblr.com/post/58650831283/accessing-a-localhost-server-from-the-genymotion
回答by sirmagid
回答by Ameen Maheen
When i used genymotion in my ubuntu
当我在 ubuntu 中使用 genymotion 时
i used the ip address of the virtual machine as local host and it worked .
我使用虚拟机的 IP 地址作为本地主机并且它工作正常。
in virtual box goto file > preferences > network > select host only network and select adapter tab copy the ipv4 address and use it instead of localhost ...
在虚拟框中转到文件>首选项>网络>选择仅主机网络并选择适配器选项卡复制ipv4地址并使用它而不是本地主机...
回答by Karthick
Check your Internet Connection on PC first, then Turn on Wifi in your Genymotion Emulator Device
首先检查您在 PC 上的 Internet 连接,然后在您的 Genymotion 模拟器设备中打开 Wifi
After goto Cmd by Pressing ctrl+r then type Cmd and hit enter you will see an command line window
按 ctrl+r 转到 Cmd 后,输入 Cmd 并按 Enter 键,您将看到一个命令行窗口
type ipconfig and hit enter...
输入 ipconfig 并按回车键...
here you can see your ipv4 address type it in your Genymotion Emulator Device's Browser now you can connect to your local webserver....
在这里你可以看到你的 ipv4 地址在你的 Genymotion 模拟器设备的浏览器中输入它现在你可以连接到你的本地网络服务器......
回答by IldiX
In my case 10.0.3.2 didn't work. I changed to virtual box host-only network : 192.168.128.2 it works. You have to try other virtualbox adapters IP if it doesn't work with 192.168.56.1. My environment is behind a corporate proxy and I was running an embedded undertow server. Hope it helps.
在我的情况下 10.0.3.2 不起作用。我更改为虚拟盒仅主机网络:192.168.128.2 它可以工作。如果它不适用于 192.168.56.1,您必须尝试其他虚拟机适配器 IP。我的环境在公司代理后面,我运行的是嵌入式 undertow 服务器。希望能帮助到你。