Android 模拟器上没有互联网 - 为什么以及如何解决?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2206822/
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
No internet on Android emulator - why and how to fix?
提问by Erik Sapir
I am trying to use internet with the Android emulator, but with no success. Any ideas?
我正在尝试通过 Android 模拟器使用互联网,但没有成功。有任何想法吗?
采纳答案by ccheneson
If by "use internet", you mean you can not access the internet from an activity while testing on the emulator, make sure you have set the internet permission in your AndroidManifest.xml
如果“使用互联网”是指在模拟器上进行测试时无法从活动访问互联网,请确保您已在 AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
If you are using the web browser, refer to Donal's post
如果您使用的是网络浏览器,请参阅 Donal 的帖子
回答by Ashwani Kumar
In order to use internet on emulator if you are setting behind a proxy server perform the following steps:
如果您在代理服务器后面设置,要在模拟器上使用 Internet,请执行以下步骤:
- Go to settings->Wireless & networks->mobile networks->Access Point Names.
Press menu button. an option menu will appear.
from the option menu select New APN.
- Click on Name. provide name to apn say My APN.
- Click on APN. Enter www.
- Click on Proxy. enter your proxy server IP. you can get it from internet explorers internet options menu.
- click on Port. enter port number in my case it was 8080. you can get it from internet explorers internet options menu.
- Click on User-name. provide user-name in format domain\user-name. generally it is your systems login.
- Click on password. provide your systems password.
- press menu button again. an option menu will appear.
- press save. try n run your browser. hope its work for you it worked for me. good luck.
- 转到设置->无线和网络->移动网络->接入点名称。
按菜单按钮。将出现一个选项菜单。
从选项菜单中选择新建 APN。
- 单击名称。为 apn 提供名称说我的 APN。
- 单击 APN。输入 www。
- 单击代理。输入您的代理服务器 IP。您可以从 Internet Explorer 的 Internet 选项菜单中获取它。
- 单击端口。在我的情况下输入端口号是 8080。您可以从 Internet Explorer 的 Internet 选项菜单中获取它。
- 单击用户名。以域\用户名格式提供用户名。通常是您的系统登录。
- 点击密码。提供您的系统密码。
- 再次按下菜单按钮。将出现一个选项菜单。
- 按保存。尝试运行您的浏览器。希望它对你有用,对我有用。祝你好运。
回答by Lengoman
If you are using eclipse try:
如果您使用的是 Eclipse,请尝试:
Window > Preferences > Android > Launch
窗口 > 首选项 > Android > 启动
Default emulator options: -dns-server 8.8.8.8,8.8.4.4
默认模拟器选项: -dns-server 8.8.8.8,8.8.4.4
回答by Dave Webb
Try launching the Emulator from the command line as follows:
尝试从命令行启动模拟器,如下所示:
emulator -verbose -avd <AVD name>
This will give you detailed output and may show the error that's preventing the emulator from connecting to the Internet.
这将为您提供详细的输出,并可能显示阻止模拟器连接到 Internet 的错误。
回答by John
I have searched long and hard for an answer to this question. From what I gather Google did that on purpose once people used the internet connection to add spam comments to the market. However, I did find a guy who had done it and was willing to share the required images.The linked AVD runs(for me) both the market and browser internet.
我一直在努力寻找这个问题的答案。据我所知,一旦人们使用互联网连接向市场添加垃圾评论,谷歌就是故意这样做的。但是,我确实找到了一个已经完成并愿意分享所需图像的人。链接的 AVD 运行(对我而言)市场和浏览器互联网。
NOTE: It looks like it's just going to fix the market. But the market won't run without internet, so if the market is fixed, the browser internet will work too. I downloaded the linked files myself and it showed the internet in the browser perfectly.
注意:看起来它只是要修复市场。但是没有互联网市场就不会运行,所以如果市场是固定的,浏览器互联网也可以。我自己下载了链接文件,它完美地在浏览器中显示了互联网。
回答by Donal Rafferty
Check your internet settings, firewalls and such may be blocking it, I know when I was working on it in college they were blocking the port number but I've never had any trouble on my home machines
检查您的互联网设置、防火墙等可能会阻止它,我知道当我在大学工作时他们阻止了端口号,但我的家用机器从未遇到任何问题
回答by Ryan
If you run into this problem and are working with a non-Windows/Mac OS (Ubuntu in my case), try starting the emulator by itself in Android SDK and AVD Manager then running your application.
如果您遇到此问题并且正在使用非 Windows/Mac OS(在我的情况下为 Ubuntu),请尝试在 Android SDK 和 AVD 管理器中自行启动模拟器,然后运行您的应用程序。
回答by 123infinity
The easiest way is to follow these steps:
最简单的方法是按照以下步骤操作:
- run android emulator 1.5
- open up the menu
- go to settings
- wireless settings(first block) and right at the bottom turn off airplane mode.
- 运行安卓模拟器 1.5
- 打开菜单
- 前往设置
- 无线设置(第一个块)和底部的右侧关闭飞行模式。
By now you would've seen on top 3g and your established connection.
到现在为止,您应该已经了解了顶级 3g 和已建立的连接。
回答by CQM
on OSX, Little Snitch was automatically denying any connection to Eclipse (and the emulator). Allow connections in Little Snitch, you have to go into Little Snitch's rules
在 OSX 上,Little Snitch 会自动拒绝与 Eclipse(和模拟器)的任何连接。在 Little Snitch 中允许连接,您必须进入 Little Snitch 的规则
回答by hzron
Allow the ADB to access the network by opening it on the firewall
通过在防火墙上打开允许 ADB 访问网络
If you are using winvista and above, go to Windows Advance Firewall under Administrative tool in Control Panel and enable it from there
如果您使用的是 winvista 及更高版本,请转到控制面板中管理工具下的 Windows 高级防火墙并从那里启用它