-
-
Notifications
You must be signed in to change notification settings - Fork 318
Setting etc hosts on android emulator
Vincent Velociter edited this page Oct 26, 2021
·
1 revision
On OSX, you probably need to have this env vars set for this to work:
export ANDROID_SDK=$HOME/Library/Android/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH
Create a custom host file for the emulator:
$ cat <local>/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# 10.0.2.2 is the emulator alias to the host loopback interface
10.0.2.2 lila.localhost assets.localhost
Push the file to emulator:
$ emulator -avd <avdname> -writable-system
$ adb root
$ adb remount
$ adb push <local>/hosts /etc/hosts
Check it is working:
$ adb shell
$ ping lila.localhost