简体   繁体   English

Xamarin.Forms Visual Studio 2017项目未部署

[英]Xamarin.Forms Visual Studio 2017 project does not deploy

I am new to Xamarin. 我是Xamarin的新手。 I used Xamarin. 我用Xamarin。 Forms template to create a sample mobile solution in Visual Studio 2017. The process created four projects Xamarin PCL, Xamarin Android, Xamarin.iOS and Xamarin.UWP. 表单模板,以在Visual Studio 2017中创建示例移动解决方案。该过程创建了四个项目Xamarin PCL,Xamarin Android,Xamarin.iOS和Xamarin.UWP。 Without making any modification to the generated solution, I am trying to run it. 在不对生成的解决方案进行任何修改的情况下,我正在尝试运行它。

The first issue is, when I set the UWP as the starting project, the Windows emulator shows up and runs the app perfectly. 第一个问题是,当我将UWP设置为启动项目时,Windows模拟器会显示并完美运行该应用程序。 But when I try to do the same with Android, I get different errors at different times based on the environment changes I make. 但是,当我尝试对Android执行相同操作时,会根据我所做的环境更改在不同时间出现不同的错误。 Finally, using the visual studio android emulator, the Phone UI shows up but not my app. 最后,使用Visual Studio Android模拟器显示Phone UI,但不显示我的应用程序。 In the background, I can see that Visual Studio completed the build process successfully without any errors but the deploy process simply hangs. 在后台,我可以看到Visual Studio成功完成了构建过程,没有任何错误,但是部署过程只是挂起了。 I left the deploy running overnight but still running in the morning. 我让部署在一夜之间运行,但仍在早晨运行。 Here is my environment. 这是我的环境。

  • Intel Core i7 processor 英特尔酷睿i7处理器
  • Virtualization enabled in BIOS 在BIOS中启用虚拟化
  • Windows 10 Education Windows 10教育版
  • 32GB RAM 32GB RAM
  • Hyper-V disabled in Windows Windows中禁用了Hyper-V
  • Executed bcdedit /set hypervisorlaunchtype off in the command window and rebooted. 在命令窗口中bcdedit /set hypervisorlaunchtype off ,然后重新启动。

I tried setting the above environment in different combinations but none of them seem to make the app work. 我尝试以不同的组合设置上述环境,但是似乎没有一个使该应用程序正常工作。 When I use an android emulator from android SDK, the build process throws errors. 当我使用android SDK中的android模拟器时,构建过程会引发错误。 The only emulator that even builds is the visual studio emulator. 甚至可以构建的唯一模拟器是Visual Studio模拟器。 But the deploy hangs. 但是部署挂起。

A second issue I have is, I have installed android SDK for version 24 and 25. But in the emulator dropdown, I can only see the emulators for 23. I checked the installation path both in visual studio and android SDK manager and they both point to the same installation folder. 我遇到的第二个问题是,我已经安装了适用于版本24和25的android SDK。但是在仿真器下拉菜单中,我只能看到针对23的仿真器。我在Visual Studio和android SDK Manager中都检查了安装路径,它们都指向到同一安装文件夹。 What do I need to make the emulators for version 24 and 25 usable? 我需要什么才能使版本24和25的仿真器可用?

I repeat, I did not make any change to the generated solution in visual studio before running it. 我再说一遍,在运行它之前,我没有在Visual Studio中对生成的解决方案进行任何更改。 I have been at it for the past three days and couldn't make it work. 在过去的三天里,我一直在努力,无法使其正常工作。 Please help. 请帮忙。

I just installed Visual Studio 2017 (on Win10 15063.138) and found, like you, Xamarin projects won't deploy to Android. 我刚刚安装了Visual Studio 2017(在Win10 15063.138上),发现Xamarin项目不会像您一样部署到Android。 Here's how I got running: 这是我的跑步方式:

  • Updated everything in the Android SDK Manager. 更新了Android SDK Manager中的所有内容。
  • Installed the new, improved Android Emulator from MS: https://www.visualstudio.com/vs/msft-android-emulator/ 从MS安装了经过改进的新Android模拟器: https : //www.visualstudio.com/vs/msft-android-emulator/
  • Used that to download/install an API level 23 (6.0 Marshmallow) emulator 用于下载/安装API级别23(6.0棉花糖)模拟器
  • Started that emulator using the same tool (you'll see it running in Hyper-V Manager) 使用相同的工具启动该仿真器(您将看到它在Hyper-V Manager中运行)
  • Selected same emulator in VS for deploy/debug (the emulators that ship with VS are painfully slow) 在VS中为部署/调试选择了相同的模拟器(VS附带的模拟器非常慢)
  • In VS, selected Android project for start-up and verified build and deploy to Android in build config mgr. 在VS中,选择要启动和验证的Android项目以进行构建,并在构建配置mgr中将其部署到Android。

Note: MS doesn't appear to have any emulators above API level 23, so Compilation and Target settings for your Android project can be the latest, but the minimum target will have to be 6.0 (API 23). 注意: MS似乎没有高于API级别23的任何仿真器,因此Android项目的“编译”和“目标”设置可以是最新的,但最低目标必须为6.0(API 23)。

After pulling my hair for the past few days, I finally got my Xamarin.Forms Android App to show my page on the emulator. 经过几天的努力,我终于有了Xamarin.Forms Android应用程序,可以在模拟器上显示我的页面。 Thanks to all the members for their suggestions. 感谢所有成员的建议。 Ryan's suggestion helped a lot ( I +1ed him, thanks Ryan) but did not solve my problem. 瑞安的建议很有帮助(感谢瑞安,我为他+1了),但并没有解决我的问题。 I googled further and found a suggestion that asked to change the following setting which did it for me finally. 我进一步搜索了一下,发现了一个建议,要求更改以下设置,最终对我有用。 So, if anyone else get stuck like I did, please do the following (in addition to cleaning up and updating all packages): 因此,如果其他人像我一样陷入困境,请执行以下操作(除了清理和更新所有软件包):

  • Open up the setting for your Hyper-V vm for your emulator (while the VM is off). 打开虚拟机的Hyper-V虚拟机设置(虚拟机关闭时)。
  • Expand the Processor node on the left and click on "Compatibility". 展开左侧的Processor节点,然后单击“兼容性”。
  • Now put a check mark on "Migrate to a physical computer with a different processor version" on the right. 现在,在右侧的“迁移到具有不同处理器版本的物理计算机”上打勾。
  • Start your emulator in the Visual Studio Emulator tool. 在Visual Studio模拟器工具中启动模拟器。
  • Now, start debug your android project in VS using the same emulator that is already running. 现在,使用已经运行的相同模拟器开始在VS中调试android项目。
  • After a delay (there is always a delay), your app will show up on the emulator. 延迟(总是存在延迟)后,您的应用程序将显示在模拟器上。 Yey!! 是的!

I just cleaned the solution and rebuilt. 我刚刚清理了解决方案并进行了重建。 Deployed and it worked again. 部署后又可以正常工作。 Deploys, has a coding error, but "runs" again. 部署,出现编码错误,但再次“运行”。 I hate issues like that. 我讨厌这样的问题。 grrr. rr

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM