Android - Modify hosts file

I use Cordova to bundle a web application as a native app for ease of distribution.

To test the site locally, but on the simulator, I needed to modify the hosts file on the Android simulator to point the test domain to the host machine:

  • Start the emulator in writeable mode:

  •   emulator <avd-name> -writeable-system
    
  • Set adb to root

  •   adb root
    
  • Remount filesystem

  •   adb remount
    
  • Log into the simulator shell

  •   adb shell
    
  • Edit the hosts file

  •   vi /system/etc/hosts
    

After this, you should be able to access the FQDN on the simulator, which will now be pointing to the specified IP.