Stay productive with rich, in-line IntelliSense capabilities as you write C code.Since I’ve recently started using Xamarin for cross platform development, I thought it would be nice to share with the community how I’ve got past some of the issues which tripped me up for a while when I was becoming familiar with it. This isn’t really a normal “getting started with Xamarin” tutorial – there’s lots of them already out there already, like this one – but hopefully anyone starting off with Xamarin will find it useful.In 2016, Xamarin was acquired by Microsoft, after that Xamarin was open source and removed payment options. No further code changes are requiredVisual Studio for Mac has first-class support for Xamarin development on macOS, it has everything you need to build, design, and test stunning, high-performance apps on Mac with a fully-powered IDE. The only thing you need to do is uninstall the Xamarin.CommunityToolkit NuGet package, install the Xamarin.CommunityToolkit.MauiCompat NuGet Package, and update the namespaces. The MauiCompat library allows us to continue using the Xamarin Community Toolkit as we use it today.
![]() Un Xamarin Studio Code Changes AreI normally just click OK here.At this point, you’ll have a simple Xamarin solution in Visual Studio 2017, which contains 4 projects – one for iOS, one for Android, one for UWP, and one shared project.Also notice that there is one file open in VS2017 after you create the solution – App.xaml.cs in the shared project. (I don’t have a Mac and I’d need Visual Studio Enterprise to use this anyway, so I normally click on the “Don’t show this again” box in the bottom left corner).Finally you’ll be prompted for the versions of Windows that you want the UWP flavour of your project to target. I also chose to create a Shared Project because I only expect my code to be used in my application, rather than shared with other developers as a Portable Class Library (you can read more about the differences between Shared Projects and Portable Class Libraries here).When you click OK, the project and files will be created, and a window like the one below will appear with instructions for setting up the Mac Agent. Compiling the solution led to multiple warnings and errorsTip: Prepare to wait a while when building the solution for the first time – it needs to download a lot of NuGet packages.Unfortunately my attempt to compile the project out of the box showed an error in the UWP project and a bunch of warning messages for the Android project. Run the application in an Android EmulatorI’ll run through some of the symptoms of problems I encountered trying the things above, and how I fixed them. Run the application in a Windows Phone Emulator Compile the application without error or warnings Things I wanted to do that didn’t work out of the box for me were: And now for the gremlins ex machinaAfter this point, I hit a few snags. ![]() Close all files from the shared project which have the type *.xaml.cs.Running in your application in the Windows Phone EmulatorTip: If you want to run your application in an emulator, you’ll definitely need a 64-bit machine which allows hardware virtualisation. Restart Visual Studio 2017 and re-open the project. Run the Android SDK manager as administrator, and install/update the recommended packages. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled“.This usually happened just after I created a project, and I found that if I close VS2017, restart it, and re-open and rebuild the solution the warning disappears.So to summarise, in order to compile the default project without errors or warnings: Getting rid of warning IDE0006 – “Error encountered while loading the project”I sometimes found that I had a warning IDE0006 which advised “ Error encountered while loading the project. Steam for mac strategy games armyUse the Android x86 emulator – but you need to turn Hyper-V offYou don’t need to uninstall Hyper-V to run the Android x86 emulator on Windows 10 – you just need to turn it off. I have never managed to successfully deploy a project to one of these emulators, even with a reasonably powerful machine.If you don’t believe me, Visual Studio even gives you a warning if you try to use them:It’s much, much faster to target one of the emulators which targets x86. The phone emulator starts up after a couple of minutes, and I was easily able to see the Xamarin application in the list of apps installed to the phone emulator.And when I run the Xamarin app in the emulator, I see the correct result – a simple form with a message saying “Welcome to Xamarin Forms!”Running your application in the Android EmulatorVisual Studio 2017 comes packaged with several Android Emulators – you can see them if you change the target project to the Android one, and look at the dropdown list on its right.Tip: I never use either the two emulators which target ARM.
0 Comments
Leave a Reply. |
AuthorAmy ArchivesCategories |