I downloaded Visual Studio 2017 for Windows to try out Xamarin forms for platform dependent development. I ran into a couple of errors and warnings. This is what helped me.
Update to the latest version, restart, rebuild, relax
I started with a fresh installation of Visual Studio 2017 15.5.0 but this has a couple of issues related to Xamarin development especially a broken project template. So updating to the most recent version (15.5.3 in my case) fixed this.
In general I noticed that whenever I create a new project, there are almost always errors or warnings showing up when the project pretends to be ready. A rebuild of the solution helps in most case. And you must not kill Visual Studio when running the first time. A couple of additional downloads are performed and some people reported problems with skipped downloads in cache (s. Troubleshooting the default install of Xamarin with Visual Studio 2017 and Windows 10 Creators Update | Jeremy Lindsay for example).
Error: No resource found that matches the given name: attr ‘colorPrimaryDark’
I had these errors quite a while when I tried out a couple of things. It seems to be caused by an incomplete or wrong Android SDK installation and project configuration. At some stage they just disappear.
warning XA0105: The $(TargetFrameworkVersion) for FormsViewGroup.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project
(The same message shows up for Xamarin.Forms.Platform.Android.dll and Xamarin.Forms.Platform.dll as well)
Go to Tools / Android / Android SDK Manager and look out for updates. Here I ran into several problems:
- I had Android 7.1 as latest which does not conform to the latest Xamarin.Forms.
- SDK Manager shows Android 8.1 at most parts but this leads to trouble. Furthermore it looked a bit messed up with duplicate entries (s. red bubbles). Thus I skipped 27 and went with Android 8.0 Platform 26:
- Tools and Platforms:
- Now you can set the correct Android versions
- The next warnings show up immediately:
Your project is not referencing the “MonoAndroid,Version=v8.0” framework. Add a reference to “MonoAndroid,Version=v8.0” in the “frameworks” section of your project.json, and then re-run NuGet restore.
After a restart of Visual Studio and rebuilding the project these disappear. If they remain I found this answer on Stack Overflow: How to use iOS simulator/Android simulator from visual studio for Mac with xamarian.forms
Now was able to pair my Samsung Galaxy Note 4 using the Live Player and deploy (sometimes you need to hit the Pair Again button). Once extablished it took about 5 seconds to see my Hello World app.
Setting UWP as startup project leads to a certicate issue:
The specified certificate has expired. For more information about renewing certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. I followed the steps described in the last section “Renewing a certificate”, and it worked. But see section Using Network Shares below for more troubleshooting hints.
I am working on a Mac with macOS 10.12 and run my Windows 10 Fall Creators update in a virtual machine with VMware Fusion out of a bootcamp partition. So I was curious to see if and how both OS play together. Coupling to the host macOS was easy via IP address and yes it workedand I found the build output on my Mac as indicated in the console at ~/Library/Caches/Xamarin/mtbs/builds/Hello4.iOS/41d16ef91e19c43f1dd83962e1fc3a86/bin/iPhone/Debug.
Connecting the iPhone via USB and debugging worked too out of the box. After all the hassle at the beginning this was impressing 🙂
Opening The Solution in Visual Studio for Mac
I created a new Visual Studio project under Windows but put it on a network share configured in the VMware settings. Now I closed the project and reopened it with a fresh installation of Visual Studio for Mac on my macOS host system.
Visual Studio for Mac needed some downloads for getting the appropriate Android version but then it works. The iOS project first complained that it cannot load Info.plist. It turned out, that it was just the wrong configuration Debug looks surprisingly similar to Debug | iPhone – sort of newbie bug 😉 After changing that I could deploy to my iPhone without any problems and the debugger started.
To cool down my paranoia, I closed the solution and reopened it under Windows – worked.
Using Network Shares
First of all it is a bit annoying that Visual Studio shows a security warning for every project regardless whether Ask me for every project in this solution is checked or not. But there is a bigger problem when targeting UWP:
While rebuilding works, even a simple run command throws an error “[UWP]Error: DEP0700 : Registration of the App Failed“. This seems to be related to file system encryption accordign to this SO answer windows 8 – Win8: Registration of the app in the layout folder … failed – Stack Overflow and [UWP]UWP DEP0700 : Registration of the app failed, but only on network drive
At least it helped in my case to change the output path in project properties / Build to a local path
Some Useful Links