104

I am trying to use internet with the Android emulator, but with no success. Any ideas?

Erik Sapir
  • 23,209
  • 28
  • 81
  • 141
  • 4
    What exactly are you trying to do? Use the browser or other applications on the emulator, or use internet connections in your own application? – r1k0 Feb 05 '10 at 14:12
  • Try to accept some answers, you and they will get reputation – Janusz Mar 04 '10 at 10:47
  • 1
    This question has an answer that worked for a lot of folks: http://stackoverflow.com/questions/2039964/how-to-connect-android-emulator-to-the-internet – harpo Feb 15 '11 at 22:15
  • I have answered below with URL which has more details! – MduSenthil Aug 31 '11 at 23:44

9 Answers9

110

In order to use internet on emulator if you are setting behind a proxy server perform the following steps:

  1. Go to settings->Wireless & networks->mobile networks->Access Point Names.

  2. Press menu button. an option menu will appear.

  3. from the option menu select New APN.

  4. Click on Name. provide name to apn say My APN.

  5. Click on APN. Enter www.

  6. Click on Proxy. enter your proxy server IP. you can get it from internet explorers internet options menu.

  7. click on Port. enter port number in my case it was 8080. you can get it from internet explorers internet options menu.

  8. Click on User-name. provide user-name in format domain\user-name. generally it is your systems login.

  9. Click on password. provide your systems password.

  10. press menu button again. an option menu will appear.

  11. press save. try n run your browser.

starball
  • 20,030
  • 7
  • 43
  • 238
Ashwani Kumar
  • 1,143
  • 3
  • 9
  • 6
  • 7
    Not woking.. . . – includeMe May 10 '11 at 09:24
  • 3
    It works for me!! Thanks a lot! The APN I had been trying to use is set to default "internet", but it turns out you need the value to be "www". – lamwaiman1988 Sep 11 '12 at 06:16
  • 2
    It worked me but without supplying username and password, I guess it depends on the network infrastructure. Thanks! – MichalK Jul 03 '13 at 11:12
  • +1 works for with supplying username and password and yes it depends on network infrastructure – shareef Oct 22 '13 at 18:23
  • Not working.... :) – Kartiikeya Jun 20 '16 at 09:00
  • fabulously working even with corporate proxy settings. – venkata krishnan Aug 04 '16 at 04:19
  • 1
    Works fine. I had to restart the emulator though – Bryida Aug 20 '16 at 10:43
  • This should be selected as the correct answer. +1 – parohy Sep 12 '16 at 06:25
  • Thanks ! It works for me!! proxy settings not required in my personal windows8 machine. use echo %userdomain% from cmd to know the domain which required to use as domain\user-name (step 8). – sandip Apr 15 '17 at 21:29
  • @includeMe, @Kartiikeya Baleneni and if anyone else doubt if the proxy settings provided in the APN is working or not then go to @Dave Webb 's answer and follow the steps, after the emulator is running copy the log and find for the term called proxy, if you see something like "proxy not using", then you should start emulator with the following command to forcefully apply the proxy `emulator -verbose -avd -http-proxy http://username:password@host:port` – Anup May 10 '17 at 08:06
  • had to restart the emulator to reflect the changes made :) – Kugan Kumar Jul 21 '17 at 06:09
  • On some API Levels you have to bring your device in airplane mode and back after saving the APN settings to apply the changes. – Mark Kowalski Mar 01 '18 at 12:48
36

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

<uses-permission android:name="android.permission.INTERNET" /> 

If you are using the web browser, refer to Donal's post

ccheneson
  • 49,072
  • 8
  • 63
  • 68
33

If you are using eclipse try:

Window > Preferences > Android > Launch

Default emulator options: -dns-server 8.8.8.8,8.8.4.4

Andrea Lazzarotto
  • 2,471
  • 1
  • 22
  • 38
Lengoman
  • 904
  • 2
  • 12
  • 22
  • 13
    We are not using eclipse anymore. We are using Android Studio? How to do this on Android Studio? – Neon Warge Jun 21 '16 at 02:10
  • 6
    command line: `emulator -avd Pixel_C_API_26 -dns-server 8.8.8.8,8.8.4.4` – Tom Nov 15 '17 at 02:30
  • 1
    adding -dns-server 8.8.8.8,8.8.4.4 to my emulator command line solved the issue for me. Android had no internet before, now it has. Running on Win10. I'm puzzled why that command line argument was necessary though? – mipnw Apr 01 '18 at 03:18
18

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.

David Webb
  • 190,537
  • 57
  • 313
  • 299
4

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

Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
3

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.

Ryan
  • 392
  • 2
  • 11
1

The easiest way is to follow these steps:

  1. run android emulator 1.5
  2. open up the menu
  3. go to settings
  4. wireless settings(first block) and right at the bottom turn off airplane mode.

By now you would've seen on top 3g and your established connection.

user
  • 86,916
  • 18
  • 197
  • 190
0

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

CQM
  • 42,592
  • 75
  • 224
  • 366
-2

Allow the ADB to access the network by opening it on the firewall

If you are using winvista and above, go to Windows Advance Firewall under Administrative tool in Control Panel and enable it from there

Rahul Sharma
  • 2,867
  • 2
  • 27
  • 40
hzron
  • 37
  • 1
  • 1