Reputation: 2886
What I did. To work with testing api I need to add specific ip and host name into hosts file. So I edited config on my pc system/etc/hosts. After that I could use my host on PC browser.
Then I tried to open same host on Android Studio Emulator (same PC). And the browser shows error "webpage not available ... ERR_NAME_NOT_RESOLVED". Strange, because, I assumed the emulator would use PC OS hosts properties (like on Mac with X-Code emulator).
Emulator error in browser img: _
So I rooted emulator, changed it hosts file same way as on PC and rebooted emulator - the same error in browser.
It seems like Android Emulator ignores both PC hosts file settings and its own. How to make emulator work with my host ip-hostname pair? Maybe I missed something?
Upvotes: 1
Views: 2821
Reputation: 2246
The last line in the devices hosts
file must terminate with a new line.
Upvotes: 3
Reputation: 2886
Sysadmin somehow resolved this situation on his side. So now I use the -dns-server option to manually specify the addresses of DNS servers. And my testing api requests work.
emulator -avd nexuss5 -dns-server xxx.xx.x.x
Upvotes: 0
Reputation:
According to the Emulator doc this is intended behavior:
Note that this usually means that the emulator ignores the content of your "hosts" file (/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS on Windows).
You, however, can access your host machine from inside the emulator with 10.0.2.2 (instead of testing in your example)
Upvotes: 0