I am doing some hacking with Android and building an app using various open source technologies such as lawnchair, xui, and Titanium and came to a point where I needed to simply view a web page that was running locally on my development machine, in my case on the localhost . So after launching the Android emulator and opening the browser, I tried typing in http://localhost, http://localhost:8000, and even the IP address http://127.0.0.1 but all to no avail.
So after doing some digging I found an article somewhat related that called for modifying your hosts file. However, this didn’t work for me either.
So it was onto Android’s online documentation. Yikes, I know. Nonetheless, I found EXACTLY what I was looking for almost immediately. According to the authors of this section of the documentation
Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine’s network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet to a router/firewall.
As it turns out the virtual router that is running actually has its own internal loopback interface which is the same as the loopback interface address on my development machine, 127.0.0.1. However, the key is the special alias that the virtual router provides to your localhost’s loopback interface, that address is 10.0.2.2.
So just type http://10.0.2.2 into the browser from the Android emulator and you’ll be requesting from http://127.0.0.1 on your development machine.
Browse Timeline
- « Distributed Collaboration – Building a Website Remotely
- » Nexus One Review From a Programmer and UI Engineer’s Perspective

