Unable to resolve host "<URL here>" No address associated with host name [closed]
In my Android application for reading RSS links, I am getting this error:
java.net.UnknownHostException: Unable to resolve host "example.com"; No address associated with hostname.
In my emulator I can connect to Google through a browser. Please help me to resolve this issue.
You probably don't have the INTERNET
permission. Try adding this to your AndroidManifest.xml
file, right before </manifest>
:
<uses-permission android:name="android.permission.INTERNET" />
Note: the above doesn't have to be right before the </manifest>
tag, but that is a good / correct place to put it.
Note: if this answer doesn't help in your case, read the other answers!
I've seen this problem in the emulator as well. In my case, it is caused by launching the emulator, then putting the computer to sleep or changing the network connection (going from work to home, etc), then attempting to use the same emulator again. Closing and re-launching the emulator resolves the problem in this case.
It is WiFi bug due to wifi disable or not properly connected.
Simply Reconnect the wifi will solve the issue.
Unable to resolve host “”; No address associated with hostname
you must have to check below code here on your manifest :
<uses-permission android:name="android.permission.INTERNET" />
and most important at least for me:-
enabled wifi connection or internet connection on your mobile device
Sometimes, although you add <uses-permission android:name="android.permission.INTERNET" />
in the AndroidManifest and you have a WiFi connection, this exception can be thrown. In my case, I have turned off WiFi and then turned it on again. This resolved the error. Weird solution, but sometimes it works.