Push Hosts file to Android Simulator

Shuckle

Shuckle

2 years ago · 3,777 views Ranger Pick
echo "loading emulator"
tools/emulator -avd Test -partition-size 128 &
./platform-tools/adb -s emulator-5554 wait-for-device
echo 'Emulator ready, pushing hosts!'
./platform-tools/adb -s  emulator-5554 remount
./platform-tools/adb -s  emulator-5554 push hosts /etc/hosts
echo 'done'

Raw

For testing a local website using a custom hosts file on the Android emulator you need to run a few commands. This script wraps them all so you can just do ./run_emulator and away you go.

Put a bash file with the content in the Android SDK root along with the hosts file you want to use (I called the script run_emulator.sh, but whatever):

Chmod it to be executable.

Assumes you already have an Android emulator called Test and are just running the one device.

Tagged: android bash emulator hosts file script shell web develoment
Comments are only visible to Forrst members. Log in or Request an invite.
3 new notifications