I need to force the Android phone emulator mapping, the way I have it configured in my /etc/hosts on my laptop. So I would want a situation where every time it tries to go to my.great-website.local, it targets my local host machine instead of going to the Internet. I have a configuration on my laptop where if I write https://my.great-website.local I am being redirected to the localhost environment. I would want to have the same effect on the emulator, but I see that its quite not easy to do. Is there an accessible /etc/hosts file on the emulator where I can try to reroute the request to 10.0.2.2 IP (special alias to my host loopback interfacem 127.0.0.1 on your development machine)?
EDIT:
I have found a great instruction on how I can edit /etc/hosts in the emulator which goes like that (MacOS specific manual):
Start Emulator
While on${ANDROID_HOME}/emulator:
./emulator -list-avds
./emulator -avd <emulator-name> -writable-system
Define Emulator hosts
While on${ANDROID_HOME}/tools:
adb root
adb remount
adb pull /system/etc/hosts Downloads/hosts
echo ‘10.0.0.1 pretty.url.of.yours\n’ >> Downloads/hosts
adb push Downloads/hosts /system/etc/hosts
adb reboot
Unfortunately just after adb remount I get an error Device must be bootloader unlocked.
EDIT 2: Second option would be to run the emulator with a DNS that has this mapping done:
emulator @Nexus_5X_API_23 -dns-server 192.0.2.0,
192.0.2.255
But unfortunately when I tried dnsmasq I constantly got some permission errors:
dnsmasq: failed to create listening socket for 192.168.224.5: Permission denied
If anyone finds an easy way to achieve this, I'd be really grateful for some help.