How to connect android emulator to the internet

2018-12-31 07:48发布

How can I connect my Android emulator to the internet, e.g. to use the browser? I've found lots of advice on what do to when your connected through a proxy, but that's not the case here, my machine (Windows 7) is directly connected to the router.

30条回答
何处买醉
2楼-- · 2018-12-31 07:55

If you're on MacOS with 2.2 and you keep seeing an error about data connectivity, try the above, it works.

  • I removed all the network interfaces via Sys Prefs except LAN
  • Even thought my DNS is provided by DHCP, I retyped DNS with just one server
  • I used -http-proxy on the command line to specify one

It starts working at the office. Phew.

查看更多
高级女魔头
3楼-- · 2018-12-31 07:56

I think some of the answers may have addressed this, however obliquely, but here's what worked for me.

Assuming your problem is occurring when you're on a wireless network and you have a LAN card installed, the issue is that the emulator tries to obtain its DNS settings from that LAN card. Not a problem when you're connected via that LAN, but utterly useless if you're on a wireless connection. I noticed this when I was on my laptop.

So, how to fix? Simple: Disable your LAN card. Really. Just go to your Network connections, find your LAN card, right click it and choose disable. Now try your emulator. If you're like me, it suddenly ... works!

查看更多
裙下三千臣
4楼-- · 2018-12-31 07:57

I have Mac OS X 10.7.2, Eclipse Helios Service Release 2. I also work via Proxy and my IP settings are via DHCP. I solved this issue firstly using this article http://www.gitshah.com/2011/02/android-fixing-no-internet-connection.html, then I removed Emulator settings and just go to Run->Run Configurations->Target->Additional Emulator Command Line Options and type there -http-proxy xxx.xx.111.1:3128 . Also I would like to say that when I typed also a DNS like this: -dns-server xxx.xx.111.1 -http-proxy xxx.xx.111.1:3128 it did not work, but when I removed DNS it worked. Also I would like to note, that Additional Emulator Command Line Options are not visible without scrolling to the bottom of that window. I also want to note, that when you change emulator options, all apps will work. But If you write Additional Emulator Command Line Options, you need to write them every time for every app target in Run Configurations.

查看更多
倾城一夜雪
5楼-- · 2018-12-31 07:59

I encounter this issue when I first run the simulator, I solved it by setting the dns server with

Library/Android/sdk/platform-tools/adb shell getprop net.dns1

get the current dns server of simulator 10.0.2.3

Then set it to my lan dns server

Library/Android/sdk/platform-tools/adb shell setprop net.dns1 192.168.1.1
查看更多
与君花间醉酒
6楼-- · 2018-12-31 08:01

My platform: Mac OS 10.6.4 Eclipse: 3.6

I had a similar problem where my map app background was grey (no tiles) and the browser was unable to connect to the internet.

Within Eclipse I went to Run Configurations -> Target and added "-dns-server X.X.X.X" and everything worked fine afterwards. (obviously X.X.X.X was the IP address for my DNS server).

查看更多
深知你不懂我心
7楼-- · 2018-12-31 08:02

If you are on Mac - try this -

  1. GoTo Apple Icon -> System Preferences -> Network
  2. Click on the gear icon on the and select 'Set Service Order'
  3. Bring the active interface before other interface.
  4. Restart the Android Emulator.
查看更多
登录 后发表回答