简体   繁体   English

为什么在选择设备时 Visual Studio 会尝试部署到模拟器

[英]Why does Visual Studio attempt to deploy to emulator when device is selected

Problem问题

I am running Visual Studio 2017 and attempting to deploy a Xamarin app to my Android hardware (Motorola Moto G 4) which is plugged in to my computer via USB.我正在运行 Visual Studio 2017 并尝试将 Xamarin 应用程序部署到我的 Android 硬件(摩托罗拉 Moto G 4),该硬件通过 USB 插入我的计算机。 When I attempt to deploy to it in Visual Studio, I get the following output:当我尝试在 Visual Studio 中部署到它时,我得到以下输出:

Starting deploy Android_Accelerated_x86 ...
Starting emulator Android_Accelerated_x86 ...
C:\Users\vchelaru\AppData\Local\Android\ANDROI~1\tools\emulator.EXE -partition-size 512 -no-boot-anim -avd Android_Accelerated_x86 -prop monodroid.avdname=Android_Accelerated_x86
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: Android Emulator requires an Intel processor with VT-x and NX support.  Your CPU: 'AuthenticAMD'
Emulator Android_Accelerated_x86 cannot be started.
Xamarin.Android does not support deploying the previous version. Please ensure your solution builds before deploying it.
------ Deploy started: Project: VolumeTest, Configuration: Debug Any CPU ------
Error: Cancelled
======== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
======== Deploy: 0 succeeded, 2 failed, 0 skipped ==========

Question

Why is Visual Studio attempting to start or deploy to emulator when my hardware is selected?为什么在选择我的硬件时 Visual Studio 会尝试启动或部署到模拟器?

What I've tried我试过的

The USB debugging is connected according to my Android device and I have authorized the device for debugging on the device. USB调试是根据我的Android设备连接的,我已经授权设备在设备上调试。 In fact, I've even been able to deploy to this device a few times, but now I can't do it anymore.事实上,我什至能够部署到这个设备几次,但现在我不能再这样做了。

The Motorola Moto G 4 is selected in the dropdown next to the "play" button in Visual Studio.在 Visual Studio 中“播放”按钮旁边的下拉列表中选择了 Motorola Moto G 4。 I've rebuilt the project, and have selected Tools -> Android -> Restart ADB Device .我重建了项目,并选择了Tools -> Android -> Restart ADB Device When restarting, the Motorola Moto G 4 device temporarily disappears, but then it's found again.重新启动时,摩托罗拉 Moto G 4 设备暂时消失,但随后又被找到。

I've tried unplugging and plugging the hardware back in. I've attempted restarting Visual Studio.我试过拔下并重新插入硬件。我试过重新启动 Visual Studio。 Whenever I do this, the hardware device is selected by default so I know Visual Studio sees it.每当我这样做时,默认情况下都会选择硬件设备,所以我知道 Visual Studio 会看到它。

I've also tried restarting Windows.我也试过重新启动 Windows。

I don't know if this resolves the core issue (which maybe is a Visual Studio/Xamarin Bug) but I did find a workaround.我不知道这是否解决了核心问题(可能是 Visual Studio/Xamarin 错误),但我确实找到了解决方法。

  1. Go to Tools -> Android -> Android Emulator Manager转到工具-> Android -> Android 模拟器管理器
  2. Make sure the Android Virtual Devices tab is selected确保选择了Android Virtual Devices选项卡
  3. Select any device which is x86 and click the Delete... button.选择任何 x86 设备,然后单击删除...按钮。
  4. Press the Refresh button to verify no x86 devices are still in the list按“刷新”按钮验证列表中没有 x86 设备
  5. Close the window关闭窗口
  6. Rebuild the project重建项目
  7. Press the play button to deploy播放按钮部署

This solved it for me.这为我解决了它。 Removing all x86 devices somehow told Visual Studio to no longer attempt to deploy an x86 emulator, and I was able to run on device.以某种方式移除所有 x86 设备后,Visual Studio 不再尝试部署 x86 模拟器,并且我能够在设备上运行。

If you are using an emulator, you need to install Intel HAXM before proceeding.如果您使用的是模拟器,则需要在继续之前安装英特尔 HAXM。 And try not to use 64bit emulators as they may open but will not display anything.并且尽量不要使用 64 位模拟器,因为它们可能会打开但不会显示任何内容。 Also they are not good for performance.它们也不利于性能。 Here is the link for HAXM 这是HAXM的链接

If you are using a physical device, make sure you check the target of your application in Your_App -> Properties and select the proper API your mobile has.如果您使用的是物理设备,请确保在 Your_App -> 属性中检查应用程序的目标,并选择您的移动设备具有的正确 API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么当我从Visual Studio调试但在部署到IIS后无法正常工作时,该方法为什么起作用? - Why does this work when I debug from Visual Studio but doesn't after I deploy to IIS? 使用Visual Studio Emulator for Android从Android设备监视器查找文件 - Find files with Android Device Monitor from Visual Studio Emulator for Android 如何在Visual Studio 2010中启动设备模拟器? - How can I Launch the Device Emulator in Visual Studio 2010? 为什么Visual Studio告诉我数据库不存在而存在? - Why does Visual Studio tell me that a database exists when it does not? 为什么进入调试时Visual Studio 2010会挂起? - Why does Visual studio 2010 hang when entering debug? 当未连接到Internet时,为什么Visual Studio 2010重建速度较慢? - Why does Visual Studio 2010 rebuild slower when not connected to the Internet? Xamarin Visual Studio 中的 Android 模拟器不显示应用程序 - Android emulator in Xamarin Visual Studio does not show the app 为什么我的 .UWP 模拟器不能在 Visual Studio 中启动? - Why wont my .UWP emulator launch in Visual Studio? 在VPN中使用Visual Studio模拟器时无法连接 - Visual studio emulator doesn't connect when used in VPN Visual Studio应用程序部署 - visual studio application deploy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM