Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using System Hosts file for Android Emulators

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

like image 654
user2642193 Avatar asked Aug 01 '13 13:08

user2642193


People also ask

Does Android use a hosts file?

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.

How much RAM do I need for Android Emulator?

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.


1 Answers

With latest Android studio and tools. You can now use follow this instructions. You only need to run this once per emulator.

  1. Start the emulator with following command. This command is located under your [sdk folder]/tools directory

    emulator @[emulator name] -writable-system
    
  2. 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
    
like image 65
N.S. Avatar answered Sep 24 '22 02:09

N.S.