android模拟器和本地站点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3243654/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:17:29  来源:igfitidea点击:

android emulator and local site

androidandroid-emulator

提问by Alexey Poimtsev

I've started android emulator app and trying to open from embeded browser locally started web-site, but local dns name (from /etc/hosts) is not resolved. Is there any option to enable local resolving?

我已经启动了 android 模拟器应用程序并尝试从本地启动的网站的嵌入式浏览器打开,但本地 dns 名称(来自 /etc/hosts)未解析。是否有任何选项可以启用本地解析?

回答by TheCottonSilk

Refer this URL. The issue is 127.0.0.1 is not the correct IP for accessing local server sites on emulator.

请参阅此网址。问题是 127.0.0.1 不是在模拟器上访问本地服务器站点的正确 IP。

http://localhost:8080/MyTestPage.html // URL to use in computer browser
http://10.0.2.2:8080/MyTestPage.html  // URL to use in emulator browser

However, you need to do some configuration changes as suggested in the URL.

但是,您需要按照 URL 中的建议进行一些配置更改。

回答by Ranhiru Jude Cooray

Here's how to access a locally hosted website in the Android emulator.

以下是在 Android 模拟器中访问本地托管网站的方法。

  1. Use IIS/Apache to host the application.
    For some obscure reason, Android Virtual Device would not let you connect to the development server created by Visual Studio.

  2. Once you host the application, use your IP address as the web address to connect to the local website. "localhost"just won't work with the AVD. Just go to the command prompt and type ipconfig to get your local ip address. You should be looking for IPv4 Address

  1. 使用 IIS/Apache 托管应用程序。
    出于某种晦涩的原因,Android 虚拟设备不允许您连接到由 Visual Studio 创建的开发服务器。

  2. 托管应用程序后,使用您的 IP 地址作为 Web 地址连接到本地网站。 “本地主机”只是不适用于 AVD。只需转到命令提示符并键入 ipconfig 即可获取您的本地 IP 地址。您应该寻找IPv4 地址

Here's Android AVD connecting to Apache (XAMPP)

这是连接到 Apache (XAMPP) 的 Android AVD

https://drag2up.appspot.com/Z6xc

https://drag2up.appspot.com/Z6xc

Here's connecting to IIS

这是连接到IIS

alt text

替代文字

Good Luck everyone and happy testing!!

祝大家好运,测试愉快!!

回答by Fedor

You should specify your local ip address in browser, something like 192.168.xx.xx

您应该在浏览器中指定您的本地 IP 地址,例如 192.168.xx.xx