views:

631

answers:

2

I develop all my sites on a OS 10.5.8 server with PHP and MySQL, and I've configured my /etc/hosts and httpd.conf files to display my site at example.dev in any browser on that machine.

I recently installed Android's software development kit which I'd like to use to develop and test stylesheets targeted to mobile Webkit-- but I can't access my locally-hosted projects in the Android browser.

This makes sense, since it's emulating the whole Android OS, but is there a workaround? Or can I only test projects that exist somewhere on the actual computer internet, perhaps in a hidden directory?

Someone suggested that I edit my /etc/resolv.conf file, but I don't know the correct way to format a locally-hosted domain in the resolv.conf-- I tried variations of the following, and nothing works:

domain example.dev
nameserver 127.0.0.1

Or...

domain example.dev
nameserver localhost

In my hosts file, it is set up like this:

127.0.0.1   localhost example.dev example2.dev [etc]
A: 

I worked around similar issue by using computers IP address in local network.

JaanusSiim
+1  A: 

You should be able to use the IP address of your mac in the URL from the android emulator and be able to access your sites that way. Of course, make sure that Web Sharing is turned on under Sharing in System Preferences, and that your firewall isn't blocking the address.

Alternately, you can use the virtual host IP address, which is 10.0.2.2. This will always map to your host mac when running the emulator.

If for some reason you prefer not to use IP addresses in your urls, you can map your mac's IP address to any name you choose by modifying /etc/hosts in your emulator. To do so, you'll need to first make the filesystem read-write, then add your mac's IP and whatever hostname you want to /etc/hosts:

adb -e shell
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
# echo '10.0.2.2      cat-yodeling.local' >> /etc/hosts

Then access "http://cat-yodeling.local" from your browser. You should be good to go.

Mike