Solution to : Android Emulator not connecting to internet even though there is internet connection on computer


For the past 2 days,I was boggled by my android emulator not connecting to the internet even though there was internet on my computer.Before going into quick fix,I would like to explain my scenario

My Scenario !!

Previously,there was proxy server at my office,and recently the proxy server was removed.Though I had unset all the proxy settings from my Lucid Linux,my android emulator was still using proxy settings.I came to know about this by running the emulator from terminal by using
emulator -avd laaptu2.3 -verbose
Here put your emulator name at laaptu2.3
At the terminal,it showed that the emulator is taking the my previous proxy settings.

Road to solution !!!

First I had to unset the proxy settings,that was still on my Ubuntu machine.This happened due to the fact,that while unsetting proxy settings,my Ubuntu machine wasn’t able to apply it system-wide even though I clicked apply system-wide option.The first place to unset proxy settings was from environment variables and you can edit environment variables via
sudo gedit /etc/environment
And remove all proxy settings options,if present there.Now,restart the computer.

Main Solution !!!

After starting your machine, start the emulator via the following ways
Step 1:
emulator -avd laaptu2.3 -dns-server 8.8.8.8 -verbose
Emulator on dns server
adb server

Take a look at second picture and it may be possible that your adb server won’t start.First close the running emulator and execute following command on the terminal

adb kill-server
adb start-server
emulator -avd laaptu2.3 -dns-server 8.8.8.8 -verbose

Here 8.8.8.8 is the dns-server for Google.com,and after searching so many forums and solution,this method really works.

Step 2:
It may seem tedious to add always the dns server from terminal.So for that,you can set this parameter on eclipse and for that follow the steps

Go to run i.e. the green arrow sign on eclipse
Then navigate to run configurations
And a configuration window will be presented
Go to target
And finally to Additional emulator command line options

Eclipse additional command line

And apply the changes.Now your emulator can browse the internet.Above solution i.e. Main Solution works for Window machine too.Hope ,this saves time for some troubled developer.Have fun and enjoy 😉