本文介绍了从genymotion访问宅基地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从genymotion模拟器访问宅基地?

How can i access homestead from genymotion emulator ?

我将此行添加到模拟器hosts文件中,但不起作用:

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

192.168.10.10 myapp.app

推荐答案

这是我在Windows 10上的操作方法:

Here's how I did it on Windows 10:

我的宅基地正在ip 192.168.10.10上运行,并且有多个站点.每个都已添加到我的Windows计算机的主机文件中,可从特定域访问.例如,在我的C:\Windows\System32\drivers\etc\hosts文件中,我添加了以下几行:

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

这意味着在Windows计算机中浏览http://app1.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.

我在Windows机器上安装并设置了Android SDK.您需要配置Genymotion才能使adb从Windows命令行运行.在Genymotion中,转到设置> ADB>使用自定义Android SDK工具,然后浏览到Windows计算机的Android SDK目录.对我来说是C:/dev/tools/android

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

由于仿真器正在访问与Windows计算机相同的网络,所以您的宅基地ip也将可从该仿真器获得.因此,您可以添加与Windows计算机的hosts文件中添加的行相同的行.

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.打开命令行并运行以下命令以编辑主机文件:

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.现在,hosts文件应该位于执行pull命令的文件夹中.使用文本编辑器编辑文件,然后添加要访问的站点.例如,我添加了:

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.将hosts文件发送回仿真器

3.Send the hosts file back to the emulator

adb push hosts /system/etc/hosts

4.在仿真器浏览器中浏览到您的站点.例如:http://app1.dev您应该现在看到您的宅基地!!

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

1.检查是否在hosts文件中的最后一个站点之后添加了空行.

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

2.关闭并重新打开模拟器浏览器

2.Close and reopen the emulator browser

3.重新启动模拟器

这篇关于从genymotion访问宅基地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 00:15