I want to access localhost from android studio emulator or from genymotion without typing the IP address instead typing as localhost or as domain name.
If you are into web development you could under stand more like we assign domain for IP in the C:\Windows\System32\drivers\etc\hosts
file in windows system.
I tried out steps from some blogs but couldn't figure it out.
Please do help me out. Thanks!
You can try editing the hosts file from terminal of the android studio.
First go to terminal and launch the emulator
emulator -avd AVDNAME -partition-size 128
Second remount the AVD to make it writable
adb remount
Third pull the host file from emulator to your local machine
adb pull /etc/hosts
Fourth edit the host file using local editor based on the need
198.0.0.1 localhost
Finally, push the edited file from local machine back to emulator adb push hosts /etc/hosts
Now, type localhost or domain you assigned in the host file.
Hope this is enough!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With