i am having difficulties to have my android app running in the emulator to connect to servers in my local network. i am getting a

java.net.UnknownHostException

but the servers are resolvable fine from the machine where the emulator is run.

thanks for any help on this topic!

You need to give it your machine local IP not localhost or 127.0.0.1

hi i"ve done my search and i know that 127.0.0.1 refers to the android loopback interface so if instead of localhost or 127.0.0.1 i should use 10.0.0.2 the thing is that my URL doesn't include my machince ip or anything like that.For example the url that i want to refer to is in this format: http://server1:81/wcf.svc and my application cannot resolve server1 because it's only a local server.It would access it normally if my sever would be on internet.

Is 10.0.0.2 what your ipconfig command returned in terminal? I would have expected something along the line of 192.168.1.x where x can be any number between 0-255.
Bellow is output from my Mac, en1 one shows that my IP on wireless network is 192.168.1.7

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 60:fb:42:f0:47:e4 
    media: autoselect
    status: inactive
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
    lladdr 60:fb:42:ff:fe:f0:47:e4 
    media: autoselect <full-duplex>
    status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 00:26:bb:15:5c:e0 
    inet6 fe80::226:bbff:fe15:5ce0%en1 prefixlen 64 scopeid 0x6 
    inet 192.168.1.7 netmask 0xffffff00 broadcast 192.168.1.255
    media: autoselect
    status: active

no 10.0.0.2 is what my virtual device considers that my developing machine's ip is...but still i don't want to connect it in my machine but in a server which my machine is connected to...

You need to provide IP of the machine on which server is running, and not some fictional IP that people mentioned on internet as example. When you get that IP you will be able to call localhost:8080/index.html as for example 192.168.0.1:8080/index.html

yes what i'saying here is that the url of my webservice doesn't include my localhost.Also i know the ip of the local server.In my search i found out that i should open the emulator with and option of -dns-server <server/ip address> and hopefully it should work

Somebody configured server you trying to use and set it. That someone said when I call server1:81 I'm calling IP 192.168.0.1 (just example). It is like daniweb.com is actually 74.53.219.188. So find IP of that server for the network and use IP of it.

Sorry for confusion, but I misread your original post and asumed that we are talking about local server

ok the way I found out was the following: executing the emulator from the cmd and then and adding the -dns-server xxx.xxx.xxx.xxx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.