Android emulator not using windows host file?

m3 http://img245.imageshack.us/img245/461/65254534.jpg

Chrome using a Windows HOST file:

m1 http://img266.imageshack.us/img266/9380/59750633.jpg

Android emulator:

m2 http://img821.imageshack.us/img821/7363/19470766.jpg

change

"On Windows, the emulator receives addresses by calling the GetNetworkParams () API. Note that this usually means that the emulator ignores the contents of your hosts file (/ etc / hosts on Linux / OS X,% WINDOWS% / system32 / HOSTS on Windows )

How can I use static IP addresses in the emulator?

+6
android android-emulator dns
source share
3 answers

FWIW, it is not possible to modify the phone’s own /etc/hosts file in the emulator - it is in the read-only file system.

Personally, I ran a local resolving server on your PC, name your Windows O / S, and then override the entries correctly.

Unbound does the job and has a nice feature that allows you to embed "local data" in your DNS results.

+3
source share

I got this article, it explains how to edit the hosts file. I don't know if this works again, but it can help.

BROKEN (February 2015) - http://www.bradcurtis.com/2011/02/13/hosts-file-google-android-emulator/ (Leaving it if restored)

If I’m not mistaken, they moved the link here , I’m not sure if it is the same article, I haven’t touched this since May 2012. http://www.bradcurtis.com/hosts-files-and-the-google-android-emulator/


EDIT: Adds a new link that works and reports an ame error (not sure if this is the same article.

+4
source share

You can update the native host file of your Android phone:

 adb remount adb push hosts /etc/system/hosts (most tutorials suggest this file) adb push hosts /system/etc/hosts (some VM systems seem to prefer this file instead!, for me this worked) 

if there are any problems, for example, I accidentally got a "read-only file system" error 90% of the time when I tried to execute above, and then try to run adb root 'before above (didn't work for me) , or start the Android VM manually using your Android sdk emulator.exe:

 emulator.exe -avd Nexus_6_API_23 -partition-size 512 

(some hints recommend manually partitioning the size of the partition, so is it easier to write to the virtual machine ?, it seems to have worked better, but still got random read-only errors). The Android virtual machine created using GenyMotion seemed a lot more stable and never got a read-only problem with their virtual machines when I tried to push the hosts file.

If the website you want to look at is hosted on your host computer, you can specify it via special IP-android virtual machines as the host machine through the hosts file:

 10.0.2.2 test-drupal8.localhost 

or, if you use Bridged Networking instead of NAT (pretend your Windows host machine is 172.16.6.50, where your website is located, and Android VM is 172.16.6.51), then you can directly use windows ip:

 172.16.6.50 test-drupal8.localhost 

Note. Make sure that Windows Firewall / Antivirus / Firewalls are disabled if you test, as they block my URLs until I turned them off.

0
source share

All Articles