Can not install MvvmCross 9.0.9 (.NET6) creating a new android project in VS2022

400 Views Asked by At

I'm trying to install MvvmCross 9.0.9 for a new beginner project, reading the steps for TipCalc tutorial and used the newest version of it (https://github.com/MvvmCross/MvvmCross-Samples/tree/master/TipCalc), which works fine. But if I try to install MvvmCross package for brand new project with NuGet it says this or if I add the reference to XXX.Core it gives me:

Warning Project '..\XXX.Control.Core\XXX.Control.Core.csproj' targets 'net6.0'. It cannot be referenced by a project that targets 'MonoAndroid,Version=v12.0 .

For XXX.Core there is no problem installing MvvmCross. Can anyone tell how to set up a new project without this behavior? I don't know what exactly I could have overlooked.

First I created a new .Core project with .NET6 library class as in the tutorial mentioned and installed MvvmCross package, added ViewModels etc.. No problems here. Then added the .Droid Xamarin project (Blank App). Everything step by step. After getting error, I tried different target frameworks changed here and restarted VS and rebuild. Still same behavior. Unfortunately I haven't been able to find much about it here and as a newcomer to MvvmCross/Xamarin I also have difficulties finding current examples or tutorials for the latest version, so I welcome any help.

1

There are 1 best solutions below

0
Liyun Zhang - MSFT On

Just as the message said, the MvvmCross 9.0.9 is support the .net6.0 not the .NetFramwokr and MonoAndroid which the xamarin.android used.

So if you want to use the MvvmCross nuget package in the Xamarin.Android project, you need to use the lower version which supports the .NetFramwokr and MonoAndroid. Such as the MvvmCross 8.0.2.

You can also try to migrate the xamarin.android project to the .net 6.0 according to this document about Migrating Xamarin.Android Applications to .NET 6. And then you can install the MvvmCross 9.0.9 in the migrated project.

In addition, you said:

No problems here. Then added the .Droid Xamarin project (Blank App). Everything step by step. After getting error, I tried different target frameworks changed here and restarted VS and rebuild

I can't understand what does the added the .Droid Xamarin project (Blank App) mean. But you can create a new .net core app which target framework is .net 6.0. Such as:

enter image description here

And then copy the code and file in your old project to this new project. After this, you can also use the MvvmCross 9.0.9 in it.