Visual Studio Android Emulator没有互联网连接

时间:2021-05-02 18:55:25

I'm using Android Emulator that comes with Visual Studio 2015. When I run it, in Wi-Fi settings of Android this status appears Obtaining IP Address.. for Wired eth1 network. But it fails after a long time.

我正在使用Visual Studio 2015附带的Android Emulator。当我运行它时,在Android的Wi-Fi设置中,此状态显示为有线eth1网络获取IP地址..但经过很长一段时间,它失败了。


What I've tried:

  • Removed all the virtual switches in Virtual Switch Manager of Hyper-V before running the emulator.
  • 在运行模拟器之前,删除了Hyper-V的Virtual Switch Manager中的所有虚拟交换机。

  • Unchecked automatic detect settings in proxy settings
  • 代理设置中未选中的自动检测设置

  • Tried different API levels (19,22,..)
  • 尝试了不同的API级别(19,22,..)

  • Windows Phone Emulator doesn't have this problem and has internet connection.
  • Windows Phone模拟器没有此问题,并具有Internet连接。

  • Restarted my PC!
  • 重启了我的电脑!


What I guess:

When I diagnose vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch) it says it has an invalid IP address. Also inside android emulator it tries to obtain an IP. Obviously I need to give the emulator a valid IP, but I don't know how or where or what value.

当我诊断vEthernet(内部以太网端口Windows Phone仿真器内部交换机)时,它说它的IP地址无效。它也在android模拟器中尝试获取IP。显然我需要给模拟器一个有效的IP,但我不知道如何,在哪里或什么值。

How to give the Android emulator internet access? Thanks in advance.

如何让Android模拟器上网?提前致谢。

3 个解决方案

#1


67  

It looks like Android is unable to acquire an IP address from DHCP.

看起来Android无法从DHCP获取IP地址。

In Hyper-V Manager (virtmgmt.msc), select the VM for the emulator profile you are trying to start and go to its Settings... (right click for context menu or see action pane on right side).

在Hyper-V管理器(virtmgmt.msc)中,为您尝试启动的仿真器配置文件选择VM,然后转到其设置...(右键单击上下文菜单或查看右侧的操作窗格)。

Under Hardware, make sure there are two virtual switches:

在“硬件”下,确保有两个虚拟交换机:

  1. Emulator Internal Network Adapter
  2. 仿真器内部网络适配器

  3. Emulator External Network Adapter
  4. 仿真器外部网络适配器

Emulator External Network Adapter must be listed as the second adapter -- the order matters. If they are ordered incorrectly, delete the External adapter and recreate it, giving it the same settings it had before. You can create it by clicking Add Hardware in the VM's hardware list.

必须将仿真器外部网络适配器列为第二个适配器 - 顺序很重要。如果订购不正确,请删除外部适配器并重新创建,并为其提供与之前相同的设置。您可以通过单击VM硬件列表中的添加硬件来创建它。

Visual Studio Android Emulator没有互联网连接

#2


1  

I fixed it by setting the second network adapter to Default switch and not the physical network adapterScreen Grab.

我通过将第二个网络适配器设置为默认开关而不是物理网络适配器屏幕抓取来修复它。

#3


0  

For me adding an external adapter for each physical one (lan/wifi) worked but only when the virtual LAN identification was unchecked on each of them.

对于我来说,为每个物理(lan / wifi)添加一个外部适配器,但只有在每个物理上都取消选中虚拟LAN标识时才能使用。

#1


67  

It looks like Android is unable to acquire an IP address from DHCP.

看起来Android无法从DHCP获取IP地址。

In Hyper-V Manager (virtmgmt.msc), select the VM for the emulator profile you are trying to start and go to its Settings... (right click for context menu or see action pane on right side).

在Hyper-V管理器(virtmgmt.msc)中,为您尝试启动的仿真器配置文件选择VM,然后转到其设置...(右键单击上下文菜单或查看右侧的操作窗格)。

Under Hardware, make sure there are two virtual switches:

在“硬件”下,确保有两个虚拟交换机:

  1. Emulator Internal Network Adapter
  2. 仿真器内部网络适配器

  3. Emulator External Network Adapter
  4. 仿真器外部网络适配器

Emulator External Network Adapter must be listed as the second adapter -- the order matters. If they are ordered incorrectly, delete the External adapter and recreate it, giving it the same settings it had before. You can create it by clicking Add Hardware in the VM's hardware list.

必须将仿真器外部网络适配器列为第二个适配器 - 顺序很重要。如果订购不正确,请删除外部适配器并重新创建,并为其提供与之前相同的设置。您可以通过单击VM硬件列表中的添加硬件来创建它。

Visual Studio Android Emulator没有互联网连接

#2


1  

I fixed it by setting the second network adapter to Default switch and not the physical network adapterScreen Grab.

我通过将第二个网络适配器设置为默认开关而不是物理网络适配器屏幕抓取来修复它。

#3


0  

For me adding an external adapter for each physical one (lan/wifi) worked but only when the virtual LAN identification was unchecked on each of them.

对于我来说,为每个物理(lan / wifi)添加一个外部适配器,但只有在每个物理上都取消选中虚拟LAN标识时才能使用。