Hey folk, I had a similar issue - I don't know if this will help you or not, but there's a couple things you should know about the android hosts file:
#1 - it doesn't seem to appreciate standard comments that begin with the pound sign: "#", in fact, it seems to just break the hosts file.
#2 - Special characters like ^M will render it useless as well.
What I was doing was using a master host list, of which had dozens of comments, and I realized that the comment lines were causing dismay, so I tried stripping it using the following command:
cat myhostsfile | sed -e 's;#.*;;' -e '/^[ ]*$/d' > ./mynewhostsfile
Not surprisingly, if I used vi editor to open 'mynewhostsfile' I found those pesky ^M characters flooding all over the place in place of my comments...
Android OS also doesn't appreciate these characters in it's hosts file, and I wasn't about to vi edit every single line where there's hundreds of host lines to work with.
I tried to remove the ^M using vi editor via the terminal emulator on my android first, however, my CTRL-v CTRL-M combo in vi editor was failing, so I had to end up using vi on a Linux desktop to fix this problem...if you don't have linux, I suggest using an Ubuntu Live CD (
Ubuntu homepage | Ubuntu) or install VirtualBox (
VirtualBox) or tiny linux/etc. (Please note, UnxUtils on Win32/64 encounters a problem with the sed command).
It May or May Not work on Your android, it certainly Doesn't work on my android's terminal emulator (Galaxy S / Captivate)
Once you copy/upload your modified hosts file to your linux box, to remove all "^M" characters from the host file, open a terminal and open the hosts file in vi editor:
vi myhostsfile
...and use this command within vi:
:%s/^M//g
The ^M in the above line has to be typed in by pressing CTRL+v and then CTRL+M.
Then type:
:wq
Then all I did was transfer this new file back, open android terminal emulator again, and type:
head /system/etc/hosts
Confirm that my hosts file is working proper, then type:
sync
Then ping a host in that hosts file...you Should now get a response! Enjoy!
You might also wish to reboot afterwards:
reboot
Hope this clarifies some things, I'm sure this is buried in the documentation somewhere, but whatever - some of us aren't doing this stuff professionally.