UWP project added to Xamarin is not compatible with netstandard2.0 - xamarin.forms

I have a Xamarin.Forms app (only doing things for Android now) where I added a project from an UWP app. With this, I get two erros which I cannot solve. I've found some things on the internet, but nothing for my specific situation.
The erros are:
Project UWP.Project is not compatible with netstandard2.0 (.NETStandard,Version=v2.0).
Project UWP.Project supports: uap10.0.17763 (UAP,Version=v10.0.17763).
Project UWP.Project is not compatible with monoandroid11.0 (MonoAndroid,Version=v11.0).
Project UWP.Project supports: uap10.0.17763 (UAP,Version=v10.0.17763).
How do I solve this?

I have a Xamarin.Forms app (only doing things for Android now) where I added a project from an UWP app.
It looks you need to update the UWP project target version to 17763. For adding the new platform for existing Forms app, you may refer to this document. And please note making the following changes to UWP MainPage.xaml
Inside the <Page> tag, add: xmlns:forms=“using:Xamarin.Forms.Platform.UWP

Related

How to fix Xamarin Forms pipeline Target Framework error

Locally, I can build and run my Xamarin Forms application with no issues. In my Azure build pipelines I have my master branch failing because of my target framework version. It says it is 9.0 when it should be at least 10.0.
In my Android project file I have the framework version set to 10.0. I have made sure it is also v10 in the properties tab for the project. Yet I still get the below error.
##[error]C:\Users\VssAdministrator\.nuget\packages\xamarin.forms\5.0.0.2012\build\Xamarin.Forms.targets(188,5): Error XF005: The $(TargetFrameworkVersion) for MyApp.Android (v9.0) is less than the minimum required $(TargetFrameworkVersion) for Xamarin.Forms (10.0). You need to increase the $(TargetFrameworkVersion) for MyApp.Android.
Try to open your .csproj file,and manually modify its targetFrameworkVersion.
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
Verify that BOTH of the following project properties are set to 10.0:
Application / Compile using Android version (Target Framework).
Android Manifest / Target Android version.
https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels
If those are already both 10.0, then make sure the Azure build pipeline has up-to-date versions of Android SDKs and tools.
Another way to fix:
If you are able to create a new sample solution, and successfully build that via Azure, then start a new solution, and add all your files to it.

Xamarin Android app out of the box shows undefined Android.Support, Android.Views, Android.Content in MainActivity

I needed to rebuild my fairly ancient Xamarin Forms app from scratch and in the process arrived at a situation where I had a new working iOS app but had needed to delete the draft Android app and start it again. So as a next step I added a vanilla Android app project out of the box and immediately what I saw was that (in MainActivity) Android.Support, Android.Views and Android.Content were undefined with wiggy red lines beneath -- for example in a reference to Android.Support.V7.Widget.Toolbar.
Trying to solve the problem, I set each of Target Framework, Minimum Android Version and Target Android Version to Android 9.0 Pie (API Level 28). In SDK Manager I checked that Android SDK Location and Java SDK Location were 'Found' and that Android SDK Platform 28 was installed.
The following NuGets came installed along with the project, I deleted them and reinstalled them (removing bin/obj folders in between): Xamarin.Android.Support.Core.Utils, Xamarin.Android.Support.CustomTabs and Xamarin.Android.Support.Design.
I tried installing NuGets Xamarin.Android.Support.v7.*. And I added the Xamarin.Forms NuGet. I tried adding 'use' declarations.
None of this helped.
For comparison I separately installed a blank Android app solution-- it worked perfectly out of the box.
Android is pretty new to me - would be grateful for suggestions on fixing this.
The app has a .NET Standard 2.0 project, an iOS project, the (vanilla) Android project (all three with Xamarin Forms), and a .NET Standard 2.0 library project.
I'm using Visual Studio for Mac V8.5.4 (stable) on MacOS 10.15.3.
I noticed that the content of MainActivity.cs is quite different, depending whether the Android project is created separately or as part of a Xamarin Forms solution. Also the provided NuGets are different. So perhaps what I was trying to do, adding an Android app to an existing XF solution, is simply not allowed.
To fix the problem, I created an empty Xamarin Forms solution with Android and iOS projects, added a further empty library project, then in Finder replaced the content of all the project folders, except the Android one, with the content of the corresponding folders in my working solution (the one with a working iOS app).
Migrating to AndroidX is a good idea though.
I don't know if this will help, but you should migrate to AndroidX as soon as possible, nevertheless. Xamarin has migrated to them, starting from Forms 4.5
Here is some more information about the libraries - Introducing AndroidX for Xamarin
There is a special NuGet package for the migration - Xamarin.AndroidX.Migration. Also available is a built-in functionality in Visual Studio - here
What I can suggest is you try to migrate to AndroidX libraries, since the old support libraries won't be supported from now on, and you will surely encounter some issues if not like this one, then something else will pop-up in the future.

How do i add UWP to xamarin forms in VS2019?

I try to create a new project(xamarin form) in vs2019, and discovered that the UWP template is missing.
I created the project in vs2017 yet it did not work. now I have added a UWP project to the xamarin form app created using vs2019, how do I link them, how do I connect(refrence) the UWP to the portable library?
I want to make use of the portable library in xamarin forms that ha UWP in it, like vs2017 versions
In VS 2019 version 16.0.0 UWP head project have been removed from the Xamarin.Forms app template. However, if you install latest version of VS 2019 (16.0.1) that option should be available to you. According to the release notes:
Add option for Windows (UWP) platform when creating new Xamarin.Forms project from 'Mobile App (Xamarin.Forms)' project template.
Other then that you could just simply add UWP as a separate project and set it up for Xamarin.Forms.

An IOS Application project must reference the project containing this xaml file in order to render in the previewer

In Previewer below error is shown An IOS Application project must reference the project containing this xaml file in order to render in the previewer.
PCL reference is added in IOS project and Xamarin.forms latest nuget package is also added .
The solution is simple. This works for me in android project. The error message is self explanatory. Solution: Check your android project and make sure the dll of your PCL/.net standard project is reference. In my own case, its referenced but shows a yellow color. I deleted the reference and re-reference by right clicking on the android project=>projects=>solution=>select the PCL/.net standard project => ok ..

Cross-Platform > Class Library (Xamarin.Forms) using VS2017 will not create Droid and iOS projects

I have .Net 4.5.1 (I am not trying to target .NetStandard) and Xamarin.Forms 2.3.4.247 and latest VS2017 15.2 (26430.15). I create a new project using Cross-Platform > Class Library (Xamarin.Forms) and do not get the 2 projects for (.Droid and .iOS). Been all over Google but come up empty handed.
I am trying to follow one of the many 'getting started with Xamarin' videos/course and cannot get to first base. OK so they are using VS2015 but I have not read anywhere that VS2017 is a problem.
What do I need to look for?
When you create a new Class Library project, you will only get a PCL project. If you want to create a solution with PCL, iOS UI and Android UI project, create using Cross-Platform > Cross Platform App (Xamarin) template. Then from there you can see dialog to select Native or Xamarin.Forms template.

Resources