问题
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
回答1:
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
回答2:
Homestead runs using virtual box [or vmware] .I have used oracle virtual box .Just to be clear ,it's ubuntu os running on virtual box .So ipv4 of ethernet adapter for virtualbox host only network will work for you .On windows,
open "cmd" and run :
ipconfig
and search for "Ethernet adapter VirtualBox Host-Only Network"
and then ipv4 pest the ip with port no [8000 default],on your emulator's browser .In my case it's.
192.168.56.1:8000
Note: please check if your homestead environment working properly. My genyotion version is : 2.5.4.
I think you have solved the problem but it may help others, Thank you.
来源:https://stackoverflow.com/questions/33838399/access-to-homestead-host-from-genymotion