Access to Localhost and Virtualhost from an emulator in Android Studio?

I want to access localhost from an orroid studio emulator or from genymotion without typing an IP address, instead typing it as localhost or as a domain name. If you are engaged in web development, you can stand in the same way as we assign a domain to an IP address in a file C:\Windows\System32\drivers\etc\hostson a Windows system. I tried steps from some blogs, but could not understand.

Please help me. Thank you

+4
source share
3 answers

You can try editing the hosts file from the Android studio terminal.

First go to the terminal and run the emulator emulator -avd AVDNAME -partition-size 128

Second AVD update to make it writable adb remount

adb pull /etc/hosts

198.0.0.1 localhost

, adb push hosts /etc/hosts

localhost , .

, !

+2

localhost , . hosts android/linux /etc/hosts. .

0

Use ip 10.0.2.2 to connect the client application to the emulator with a server running on the same computer as the emulator.

0
source

Source: https://habr.com/ru/post/1690256/


All Articles