从OSX主机上的Android虚拟设备访问Vagrant无头VBox

时间:2015-07-25 11:06:11

标签: android macos vagrant virtualbox

我的Mac Mini(Yosemite)上有一个Vagrant VirtualBox(Scotchbox)和一个运行网站的盒子内的测试服务器(LAMP)。从iOS Simular和常规浏览器,我可以很好地达到它。

在同一个OSX(优胜美地)主机上的Android虚拟设备(emulator64-arm,Android 4.2.2,本机浏览器)中,我只获得了未格式化的文本和链接,没有图像。 - 见下文。  无法检查虚拟设备内的元素,所以没有帮助。 当我使用存储在主机(OSX)上的etc / hosts中的主机名site.dev加载站点时,我什么都没得到。至少我只能通过ip加载一个破损的网站。

这就是这个Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end

我从私人网络更改为公共网络,看看我是否可以从我的虚拟设备加载整个网站。这是小调整之后的Vagrant文​​件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "public_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end

当我使用vagrant reload而不是public_network运行private_network时,我看到了

vagrant@127.0.0.1's password:password
==> default: Checking if box 'scotch/box' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) en1: Wi-Fi (AirPort)
2) en2: Thunderbolt 1
3) en0: Ethernet
4) bridge0
5) p2p0
6) awdl0
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1

我选择了一个在无线网络上的人..不确定这是不是最好的选择..但后来我被告知:

NFS requires a host-only network to be created.
Please add a host-only network to the machine (with either DHCP or a
static IP) for NFS to work.

为什么我不能使用初始 Vagrantfile设置从Android Studio加载我的虚拟设备上的网站? Localhost在10.0.2.2上加载得很好。如何解决这个问题?

虚拟设备的屏幕截图 android virtual device

0 个答案:

没有答案
相关问题