Could not install package - xamarin

Could not install package 'Xamarin.Kotlin.StdLib.Jdk8 1.6.10'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v11.0', but the package does not contain any assembly references or content files that are compatible with that framework.

You can fix that by targeting Android 12.
Change:
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
To:
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
This has to be done in all your Android projects, including Library projects.
Make sure your Xamarin.Android tooling is up to date, along with having API 32 installed in your Android SDK manager.
Also don't get fooled by the AndroidUseLatestPlatformSdk property if you do not have the correct SDK installed. It will just grab the latest you have installed and if that is lower than 12, you will still have the issue.
Also make sure to restore NuGet packages after this change.

Related

Updating Xamarin Forms produces "invalid android support library configuration" error when building.

I updated Xamarin Forms to 3.4.0 on a Xamarin Forms Android project that was working fine. Now I am getting this error when attempting to build. The error is "invalid android support library configuration" and when I look at my Package Console I see this...
...saying that some of my Xamarin.Android.Support.xxx packages need a downgraded package for compatibility. Problems is, my project does not have any of this packages as you can see by my "Packages" folder here...
What am I missing or doing wrong?
This can happen if you update ALL of the nuget packages in a Xamarin.Forms Android project.
Xamarin.Forms has specific dependencies on specific versions of the Xamarin.Android.Support libraries, and if you update ALL of the nuget packages in the Android project, then the support libraries may update to versions later than the versions that the new Xamarin.Forms version supports.
At this point I would uninstall Xamarin.Forms package from the Android project and also uninstall all of the dependent support library packages, which are listed here under "Dependencies": https://www.nuget.org/packages/Xamarin.Forms/
So in the Android project, uninstall the following nugets:
Xamarin.Forms
Xamarin.Android.Support.Design
Xamarin.Android.Support.v4
Xamarin.Android.Support.v7.AppCompat
Xamarin.Android.Support.v7.CardView
Xamarin.Android.Support.v7.MediaRouter
Once uninstalled, just re-install Xamarin.Forms and the correct versions of the support packages should be re-installed.
In the future, just update the Xamarin.Forms packages and that will automatically update the support library packages if necessary, and will not update the support libraries if the newer support library versions are not supported by the updated Xamarin.Forms version.
Updating Xamarin.Forms and all *.Support.* libraries to the latest version worked for me.
You have a version compatibility problem, if you have updated some packages recently, you must go to the package manager "NuGet/Update" you will find all Xamarin packages need update.

Xamarin - Updating nuget packages caused errors

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

Cannot install NuGet packages to PCL - "package does not contain any assembly references or content files that are compatible with that framework"

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.

can't update or install any nuget packages in vs 2017

I just installed vs 2017 and wanted to run my project but i'm facing so many warning and errors so I realized I should update my xamarin.android nuget packages but I keep getting this error message below:
Severity Code Description Project File Line Suppression State Error Could not install package 'Xamarin.Android.Support.Animated.Vector.Drawable 27.0.2-preview1'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v8.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. 0
Repairing vs didn't work; deleting nuget.config didn't work; I even changed the version in .csproj file, but when i load the project it goes back to v8.0.
Can anybody please help?
can't update or install any nuget packages in vs 2017
Just as Jon said, the latest nuget package Xamarin.Android.Support.Animated.Vector.Drawable 27.0.2-preview1, which requires MonoAndroid81 at minimum to install.
However, only the latest Preview (15.6 Preview 2) version of Visual Studio includes Android 8.1 support. As this moment, current release version is 15.5.4, preview release version is 15.6 Preview 2. So if you want use that nuget package the latest version 27.0.2-preview1, you need download the latest version of Visual Studio 15.6 Preview 2 and install Android SDK 8.1.
If switch to Visual Studio 15.6 Preview 2 is not your choice, you should not update that package to the latest version, just use the version 26.1.0.1.
Hope this answer more clear.
This requires MonoAndroid81 at minimum to install. You can use the current Preview which includes Android 8.1 support:
https://blog.xamarin.com/xamarin-android-now-double-stuffed-with-oreo-8-1/
For future reference, the support library has a major version that maps with the Android version it supports. In this case Support v27 = Android 8.1 (API 27)
When errors appear, clean your solution and rebuild it.
Also do something very basic, that what you are going to download is "accessible " in .Droid and that is not only in the Portable.
If you do not serve, and do not find a solution, you must start a new project, it would be advisable to install the latest SDK, etc.

Xamarin version of Android SDK packages are not found (both Xamarin.Android and Xamarin.Forms)

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.

Resources