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:48

Here is an answer for developers using Android Studio.

Operating System : Mac OS X El Capitan

IDE : Android Studio 2.2

For some reasons, I wasn't able to access internet through my AVD at work (probably proxy or network configuration issues). What did the trick for me was to launch in command line my AVD and giving manually the Google public DNS 8.8.8.8.

In your Terminal go to the folder tools of your Android sdk to find the 'emulator' program:

cd ~/Library/Android/sdk/tools

Then retrieve the name of your AVDs :

emulator -list-avds

It will return you something like this:

Android_Wear_Round_API_23
Nexus_10_API_22
Nexus_5X_API_22
Nexus_5X_API_24
Nexus_9_API_24

Then launch the AVD you would like with the following instructions:

emulator -avd NameOfYourDevice -dns-server 8.8.8.8

Your AVD is launched and you should be able to use internet.

查看更多
深知你不懂我心
3楼-- · 2018-12-31 07:48

There are different solutions to this problem . One of these , i will show you on my experiment and outcomes seen on results using a recent android studio and AVD images downloaded 2017.

  1. First thing you have to do is launch your AVD from android studio.(in my case i choose NEXUSAPI25 android 7.1 image)

  2. Goto Settings->Wirless and Networking - > Cellular Network - > Access Points -> (+) press add - > enter the following if you dont have NTLM proxy or proxy at all (that means you are directly connected)

    a. add apn name as myAPN b. add apn server => www c. save and try browsing the internet.

if this doesn work add 'ANDROID_SDK_ROOT' in you environment variable

Then , launch AVD using emulator command as follow

emulator -avd Nexus25 -dns-server 8.8.8.8
  1. For those who use NTLM proxies , i will show you how it work for me next.

  2. add your Android_sdk_root path into your environment variable. THis make command line code read succesfully like using AVD names and so on.

  3. Launch your emaulator using the following command

>emulator -avd Nexus_5X_API_25 -http-proxy http://username:password@ipaddress:port

ENTER

enter image description here

enter image description here

查看更多
几人难应
4楼-- · 2018-12-31 07:48

I had the same problem on my virtual windows 7.

  1. Go to Network Connections
  2. Alt > Advanced > Advanced Settings...
  3. In the second tab bring the internet networks interface on the top

hope it's helpful thanks to

查看更多
低头抚发
5楼-- · 2018-12-31 07:49

In eclipse go to DDMS

under DDMS select Emulator Control ,which contains Telephony Status in telephony status contain data -->select Home , this will enable your internet connection ,if you want disable internet connection for Emulator then --->select None

(Note: This will enable internet connections only if you PC/laptop on which you are running your eclipse have active internet connections.)

查看更多
人间绝色
6楼-- · 2018-12-31 07:49

it appears there might be a few reasons why there might be no internet connection for an emulator, in my case i was working from home where i have a wireless connection then came into the office and plugged in direct, however although my wireless connection was disconnected it was not disabled resulting in no emulator connection. my understanding is that when it starts up it looks for a network adapter and if there is any conflict here it might result in no internet connection. to resolve go to Start > Settings > Network Connections right click on Wireless Network Connection (if you are not using wireless) and select disable

查看更多
浪荡孟婆
7楼-- · 2018-12-31 07:50
  1. righ click on the Project in Eclipse
  2. select Run As -> Run Configurations ...
  3. select Android Application and then select "target" tab
  4. Looking for "Additional Emulator Command Line Options" and put this command line to text box

    -http-proxy http://< username >:< password >@< hostname >:< port >

查看更多
登录 后发表回答