[英]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 错误),但我确实找到了解决方法。
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.