Search code examples
vagrantgenymotionhomestead

Access to homestead host from genymotion


How can i access homestead from genymotion emulator ?

i add this line into emulator hosts file, but not work :

192.168.10.10 myapp.app 

Solution

  • Here's how I did it on Windows 10:

    Check if homestead works

    My homestead is running on the ip 192.168.10.10 and has multiple sites. Each have been added to my Windows machine's hosts file to be available from specific domains. For example in my C:\Windows\System32\drivers\etc\hosts file i have added the following lines:

    192.168.10.10   app1.dev
    192.168.10.10   app2.dev
    

    This means when browsing http://app1.dev in my Windows machine it should be showing my site. If this is not working for you, then check homestead's official docs how to do this properly. The setup will vary on the version of homestead you are using.

    Configure adb for Genymotion

    I have Android SDK installed and setup on my Windows machine. You need to configure Genymotion for adb to work from the Windows command line. In Genymotion go to Settings > ADB > Use custom Android SDK tools and browse to your Windows machine's Android SDK directory. For me it was C:/dev/tools/android

    Edit emulator devices hosts file

    As the emulator is accessing the same network as your Windows machine, then your homestead's ip will also be available from the emulator. Thus you can add the same lines as you added in your Windows machine's hosts file.

    1.Open the commandline and run the following commands to edit the hosts file:

    adb root
    adb remount
    adb pull /system/etc/hosts hosts
    

    2.The hosts file should now be present in the folder where you excecuted the pull command. Edit the file with a text editor and add the sites you want to access. For example i added:

    192.168.10.10   app1.dev
    192.168.10.10   app2.dev
    

    3.Send the hosts file back to the emulator

    adb push hosts /system/etc/hosts
    

    4.Browse to your site in the emulator browser. For example: http://app1.dev You should see your homestead site now!

    What to try if site is not reached from browser

    1.Check that you added an empty line after the last site in the hosts file.

    2.Close and reopen the emulator browser

    3.Restart the emulator