Android Emulator Windows Hosts file editing

Oh! so you want to update a hosts file just like I wanted and spoiled many minutes playing with what works. Let’s go through this process to make it work for you as well (hopefully!)

Google Android emulator is an amazing tool to test out your apps, Hybrid or Native.

There are many cases when we want to use hosts file to point a domain to a machine located in local network.

A good place to start reading about what is or is not possible with emulator when it comes down to networking is to read this help page on Android emulator networking.

Edit the hosts file in Android emulator

  1. Start your Android Virtual Device (AVD):

    Emulator is located under “C:\Program Files (x86)\Android\android-sdk\tools” folder, we are adding the partition size so we give enough buffer to write to our hosts file without any error. The error you may get is  failed to copy ‘c:\temp\hosts’ to ‘/system/etc/hosts’: Out of memory

  2. Second step is to remount the device image by using the command below

    adb stands for Android Debug Bridge, to read more on this command please go visit this page, this program can be found in “C:\Program Files (x86)\Android\android-sdk\platform-tools” location of your windows install.

  3. Next step is to get the default hosts file and save it on your local hard drive using the command below, I am using the destination location as c:\copied, yours can be anything

  4. Make the new entries to you hosts file. Important: Now in the example below I am using a white space instead of a TAB delimiter between IP address and hostname. For me, TAB didn’t work. But you can try both to see what works for you. Also not that I am appending my entry to the existing file rather than editing it with notepad.

  5. Let’s save the edited file and send it back to the emulator.

    Now you are able to browse your domain from local network.



I hope this helps


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.