I having problem in using my system hosts file details in Android Emulators. I have my website (www.example.com) deployed in Webserver. I am trying to access those website in Emulator from my desktop. My desktop has a hosts file with the entry of
10.xx.xx.xx www.example.com
I am trying to access the www.example.com from the android emulator - browser and it is not working.
I took a reference from the below website, but most of the website says how to use the hosts file if the website is deployed in the same server.
http://sadhanasiblog.blogspot.in/2012/07/local-environment-setup-for-android.html
Please let me know if anyone has answers. Thanks in Advance.
-Senthil
The hosts file on Android devices is located in the '/etc/hosts' folder. This file is located in a read-only filesystem for security reason, it cannot be modified.
However, the heap size should not be less than 12 MB. o Depending on your computer specs, the recommended ram size is in the range between 512 MB – 1024 MB. Although you can give more ram to the emulator but an actual android device would normally have 512 MB – 1024 MB for ram only.
With latest Android studio and tools. You can now use follow this instructions. You only need to run this once per emulator.
Start the emulator with following command. This command is located under your [sdk folder]/tools directory
emulator @[emulator name] -writable-system
Open another command prompt and then switch your directory to [sdk folder]/platform-tools and run following commands
adb root
adb remount
adb shell
echo '10.0.2.2 [localserver dns name]'>>/etc/hosts -- example echo '10.0.2.2 xxxx.com'>>/etc/hosts
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