Tips to solve the UnknownHostException on Android

Lately I've seen so many java and android developers getting the annoying UnknownHostException message while trying to connect the Android emulator to the internet. I've had this problem too and I know it is how much it is really irritating. So I decided to share you guys some of things you should check before trying to make your android connect to web.

1. AndroidManifest.xml:

  • The very first thing is the AndroidManifest.xml, it got to have the permission to connect the internet. So, check if it has the following line (it is a must, don't try anything related to internet before that):

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

2. Test the connection using the web browser, to see if it's a code or an emulator problem.

  • To eliminate if the connection problem is from your code or your emulator, run a web browser and try to connect to any trustful web site like www.google.com

3. Check your firewall settings.

  • Another common problem is your firewall blocking your Android emulator to connect to the internet. In this case you should open your firewall and permit or bypass emulator connections. Below is an example of a windows firewall permitting android emulator connections.  

4 . Share your network connection (If all fails).

  • That one was tricky, I was almost giving up when this idea came to my mind, so I decided in a desperate try, share the connection on windows and BAM! My android emulator finally connected to web. See below the picture to got an idea on how I did this on Windows XP.

So that is it. That was my tips and problems that I found while trying to connect my Android emulator on the web. If you guys have another tip, please comment and share, let´s help each other and stop banging our heads on the desk. :)

Thank you for reading. Take care. See ya.

Comments 1 comment

Vito Andolini 4 years ago

I couldn't get rid of the emulator "UnknownHostExceptions". Tried everything. Finally I deleted my AVD, shut down Eclipse, and then created the AVD via the command line. Then launched it from the command line with the option -dns-server 8.8.8.8. It finally worked!

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working