Android java.net.UnknownHostException: Host is unresolved

The answer is devilishly simple: remove, then re-create your AVD (virtual device/emulator) in Eclipse. It worked for me--first time.


In my case I was downloading an XML file from a URL on my phone but was having the issue describe in this thread.

for fixing it, I not only needed to have the regular internet permission

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

But I also needed

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

As a suggestion to see if your device may need the same thing, try navigating to the URL in your phone's browser to see if prompts about needing SD Card or something.

Hope that helps others.


I been follow the steps above but still try no luck, finally i just realize my app did not allow to go outside internet in the emulator. So just add users permissions in your manifest file. Done! Thanks to jozsi see http://www.helloandroid.com/tutorials/how-download-fileimage-url-your-device

  1. android.permission.INTERNET
  2. android.permission.ACCESS_NETWORK_STATE
  3. android.permission.READ_PHONE_STATE

I have seen this on a phone as well (while doing USB debugging). The solution was to disable WiFi, and re-enable it.

Tags:

Android