I get the following error when my program attempts to connect to a URL on an Android Emulator:
java.net.UnknownHostException: www.xyz.com
at java.net.InetAddress.lookupHostByName (InetAddress.java: 513)
I then opened a browser on the emulator and typed in the url. It did not work either. However, when I typed in the IP Address into the browser, it worked!
So the issue is that host names is not getting resolved. I have tried restarting the emaulator. Deleting and creating a new AVD (Android Virtual Device) and restarting my computer. I have also checked the AndroidManifest.xml and it does have the following line at the proper place.
<uses-permission xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET" />
Its been a few months since I used the Android Emulator, but it used to work before. I fail to understand why it is not working anymore and what I can do to make it work. Please advise!
Thank you!
I found why the host name was not getting resolved. Under Network Conections, the LAN Ethernet Connection (which the system uses) did not have the right DNS servers listed. Once I corrected that, the Android Emulator was able to resolve host names fine! 🙂