I created a "Cross-Platform App (Xamarin.Forms)" app, and i immediately went and update the nuget packages (this is what i was told to do). Then i tried to built it, and not only I got several errors(see bellow) that were about the updated packages, I had code errors as well. I swear the God that i didn't touch the code of the project at all, and here is what I get:
I googled, but i couldn't find out a clean solution for this. I am just one step before quitting this (unprofessional) product, because i cannot run the ready template. Is there someone that can give me a piece of advice for these ridiculous errors ?
Could not install package 'Xamarin.XXXXXXX'. You are trying to install this package into a project that targets 'MonoAndroid,Version=vX.X'
You need to increase your "Compile Target Framework" to at least 7.0 as this error indicates.
You can review the dependancies of a package on the Nuget.org site by looking at the Dependencies section of a particular package:
https://www.nuget.org/packages/Xamarin.Android.Support.v7.AppCompat/
Another SO question/answer example that requires at least MonoDroid 8.0:
https://stackoverflow.com/a/49138485/4984832
Example:
Xamarin.Android.Support.v4 27.0.x.x requires at least MonoAndroid 8.1 to be set as the Compile Target Framework:
You have to use newer android SDK version. You can download the SDK from android SDK manager and then select it from project properties
Related
I'm building a new Xamarin Forms 5 app using VS 2022 17.1.1. Everything in the project appears to be up-to-date.
I've been working on this project for a while and never had this issue. All of a sudden it just appeared today. The last action I took was to install the Plugin.InAppBilling package, thought the package in question is not used by the Plugin.InAppBilling package.
The error is as follows:
All I can see is that the shared project is using System.Numerics.Vectors version 4.5.0 and it seems to be dependency of Xamarin.Essentials which is version 1.7.1 in my project.
However, the version number of System.Numerics.Vectors seems to be 2.0.5.0 in the Android and iOS projects.
I found the GitHub issue here but I'm not seeing any clear resolution to this issue. Even though it appears to be a warning, in my case, I can no longer run the app because I keep getting deployment error to the Android Emulator or actual device. It simply refuses to deploy my app to the device/emulator. So, it's really NOT a warning in my case. It's a show-stopper. I'm a bit surprised about how lightly the Xamarin Essentials folks seem to have taken this issue on GitHub.
Has anyone actually resolved this issue? If so, what's the solution?
BTW, in my case both the Android and the iOS projects are throwing this error/warning and both use System.Numberics.Vectors version 2.0.5.0 even though the shared project has version 4.5.0 installed as a dependency undre Xamarin Esssentials.
I'd appreciate some pointers on how to make this issue disappear. Thanks.
At first, you can try to update the Xamarin.Essentials package in the Android and IOS project with the nuget package manager to the version 1.7.1.
And then, if the error is still here, you can right click the reference and remove the reference of the System.Numberics.Vectors 2.0.5.0 both in your Android and IOS project. Then download the System.Numberics.Vectors 4.5.0 in the nuget package manager both too.
When you install a nuget in Xamarin.Forms is it necessary to do it on every project (project, project.Android and project.IOS)?
Which pros and cons has do it or how I know where I have to intall each of them?
There is no absolute answer, it will depend on the Nuget Package. So you will have to read the information about it before deciding to install it in your project.
What defines this?
Take for example Xamarin.Essentials, it is installed in all the projects because you can call the functions in share code, but the actual implementation is in the platform specific. In this case you even have to call Init in every platform
From Xamarin.Essentials doc
In the Solution Explorer panel, right click on the solution name and
select Manage NuGet Packages. Search for Xamarin.Essentials and
install the package into ALL projects including Android, iOS, UWP, and
.NET Standard libraries.
If you apply platform specific code, you might need some extra Nugets for that code, meaning that you would only add it to your Android or iOS or UWP code
If you have any doubt about where to install the package, you can always ask :) Also if you install an Android package in an iOS project, you surely will get a compiling error.
I am trying to follow a tutorial on consuming web services in Xamarin Forms. I created a fresh project and have tried to install Refit, that didn't work so I tried to install RestSharp. I can install both of these libraries to my Droid / iOS projects, but not to the PCL. I get the following error in Visual Studio:
Could not install package 'Refit 4.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author
Could not install package 'RestSharp 106.2.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author
I've found this post on the xamarin forums, but it didn't fix my issue. My project is fresh, everything is up to date... Does anyone know how I can fix this issue?
vents XF is supposed to make developing cross platform apps faster & easier, but i think I'd have done this poc in native ios/droid twice in the time it's taken me to install a library to a blank project! :)
This happens because RestSharp it's not compatible with PCL-library. So you will have to handle whatever you're trying to do in platform specific.
After an upgrade of Xamarin.Android solution I've encountered the following error:
Please install package: 'Xamarin.Android.Support.v7.AppCompat' available in SDK installer. Java library file C:\Users\YOURUSERNAME\AppData\Local\Xamarin\Xamarin.Android.Support.v7.AppCompat\24.2.1.0\content\classes.jar doesn't exist.
There are number of other android support packages mentioned too. I can reproduce exactly the same situation with Xamarin.Forms.
I've checked the paths mentioned, but i can see the correct .jar in there. Forcing a reinstall of the NuGet package does not fix the problem.
The problem is caused by broken downloaded archives or broken extracted archives content. The solution is:
Ensure you have the latest version of the packages via Android SDK
Manager (e.g. Extras -> Android Support Library)
Delete the content of
C:\Users\YOURUSERNAME\AppData\Local\Xamarin\zips
Delete the content of the corresponding to the error message
C:\Users\YOURUSERNAME\AppData\Local\Xamarin\Xamarin.Android.PACKAGE_NAME
folders
Rebuild the solution from Visual Studio
NOTE: Do not interrupt rebuild process. It takes some time to download the archives. They are relatively big.
I saw that Xamarin was now free and decided to try writing a mobile app using it instead of what another technology I was playing with. After some various hiccups, I was able to get the new Xamarin Android project to build, deploy and run on the simulator. I then decided to try out MQTT connectivity from it before I went any further. No matter which MQTT library I to install from NuGet, for example the System.Net.Mqtt one from Xamarin, I get the following error:
"Could not install package 'System.Net.Mqtt 0.3.12-pre'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
I tried several others with no success. It does the same for the ios and Android projects. I did try changing the Android SDK version to use for compiling, but still had the same result. I also don't understand why it says MonoAndroid since I thought all the Mono references were changed to Xamarin? I'm using Visual Studio 15 with Update 2. I tried the stable Xamarin version and also tried the latest alpha. I'm not sure what else to try, I'd really to give Xamarin a try for this project. I did some searching and couldn't find anything that appeared to help with this issue.
Thanks in advance for any help.
Use the Package Manager Console. Then, either:
Install the latest version of MQTT library.
Or install first its dependency, RX-Main and then MQTT.
If you still get an error, please share with us the Log that is shown in the PM Console.