androidemulationhosts-fileunknown-host

UnknownHostException at the android emulator


I've got an UnknownHostException in my android application when I want to get to my web service.

I inserted an <uses-permission android:name="android.permission.INTERNET" /> at my AndroidManifest.xml.

If I go to my link of webservice via browser it's going fine.

I typed the domain name and IP at the C:\Windows\System32\drivers\etc\hosts file.

But if I run application via emulator I got an UnknownHostException. As I understand, emulator should use my system files to connect with the server...But, practically it doesn't..Help please with this issue.


Solution

  • Problem solved using such domains as

    CustomHttpClient.executeHttpPost("http//192.168.1.2/path"); 
    

    Everything works fine with it. I can't edit hosts file in android file system even with root rights. So if you have similar problem - good solution is to use IP addresses, not domains.

    Thanks to Haresh Chaudhary