简体   繁体   English

Android模拟器未连接到互联网

[英]Android Emulator is not connecting to internet

I am using TATA PHOTON PLUS. 我正在使用TATA PHOTON PLUS。 Android Emulator browser is unable to connect to internet. Android模拟器浏览器无法连接到互联网。 The "web page not available" message is coming. “网页不可用”消息即将发布。 Do we need to make any settings for making it to connect to internet? 我们是否需要进行任何设置才能连接到互联网? Please help. 请帮忙。

Goto

 ...\android-sdk-windows\tools>

and write the following and check 并写下以下内容并检查

emulator -avd your_avd_name -dns-server 8.8.8.8

don't forget to close your previously running AVD, before applying these steps. 在应用这些步骤之前,不要忘记关闭以前运行的AVD。 Hope it works for you thanks. 希望它对你有用谢谢。

Under Windows you can change the network adapter indexing so the "internet" adapter is the first. 在Windows下,您可以更改网络适配器索引,以便“Internet”适配器是第一个。

Let's say that you use the wifi adapter to connect to internet. 假设您使用wifi适配器连接到互联网。 You have to open the PowerShell (as administrator) and execute the command: 您必须打开PowerShell(以管理员身份)并执行命令:

netstat –r -n

Among the other things you'll get the list of the network adapters, ie: 在其他事项中,您将获得网络适配器列表,即:

Interface List
 18...f0 bf 97 04 da f1 ......Realtek PCIe GBE Family Controller
 30...16 27 37 af c7 99 ......Microsoft Wi-Fi Direct Virtual Adapter
  4...64 27 37 af c7 99 ......Qualcomm Atheros AR9285 Wireless Network Adapter
  7...64 27 37 af c7 9a ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
 10...00 00 00 00 00 00 00 e0 Microsoft Teredo Tunneling Adapter
 19...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter

Running the command 运行命令

Set-NetIPInterface –InterfaceIndex "4" –InterfaceMetric "1"

you can move to the top of the list the wifi adapter and this will solve the issue. 你可以移动到列表的顶部wifi适配器,这将解决问题。

Run again the "netstat –r -n" command to verify it. 再次运行“netstat -r -n”命令进行验证。

Sometime even after setting all it may not work. 有时甚至在设置之后它可能不起作用。 If you are using eclipse for your android projects then you can try this. 如果您正在为您的Android项目使用eclipse ,那么您可以试试这个。 this works for further emulator browser connectivity as well. 这适用于进一步的模拟器浏览器连接。

Before that I have tried all the methods like 在此之前我尝试过所有的方法

  1. Setting the proxy in Emulator APN 在仿真器APN中设置代理
  2. Setting it thru eclipse preferences --> Android --> Launch 通过eclipse首选项设置它 - > Android - >启动

Nothing worked. 没有任何效果。 Then I did the following which worked instantly. 然后我做了以下立即工作。

Goto eclipse Run --> run configurations. 转到eclipse运行 - >运行配置。 Under Android Applications you can see you application. 在Android应用程序下,您可以看到应用程序。 Now, on teh right hand side click on the Target tab. 现在,在右侧单击“目标”选项卡。 Under the 'Additional Emulator Command line options' add the following. 在“其他模拟器命令行选项”下添加以下内容。 -dns-server < DNS servers from your local machine upto three > -http-proxy http://< your proxy >:< your proxy port > -dns-server < 本地计算机上的DNS服务器最多三个 > -http-proxy http:// < 您的代理 >:< 您的代理端口 >

Make sure you have defined the following permission in your AndroidManifest.xml: 确保您已在AndroidManifest.xml中定义了以下权限:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.app.myapp" >
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>

No additional config steps should be needed other than the fact that your system is connected to the internet. 除了系统连接到Internet之外,不需要其他配置步骤。 In the past when I have faced a problem similar to what you mentioned, restarting the emulator or deleting and recreating the AVD has worked for me. 在过去,当我遇到类似于你提到的问题时,重新启动模拟器或删除并重新创建AVD对我有用。 I am interested in experimenting with suri's answer though.. 我有兴趣尝试suri的答案..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM