简体   繁体   中英

Android Emulator is not connecting to internet

I am using TATA PHOTON PLUS. Android Emulator browser is unable to connect to internet. 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. Hope it works for you thanks.

Under Windows you can change the network adapter indexing so the "internet" adapter is the first.

Let's say that you use the wifi adapter to connect to internet. You have to open the PowerShell (as administrator) and execute the command:

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.

Run again the "netstat –r -n" command to verify it.

Sometime even after setting all it may not work. If you are using eclipse for your android projects then you can try this. 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
  2. Setting it thru eclipse preferences --> Android --> Launch

Nothing worked. Then I did the following which worked instantly.

Goto eclipse Run --> run configurations. Under Android Applications you can see you application. 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 >

Make sure you have defined the following permission in your 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. 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. I am interested in experimenting with suri's answer though..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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