Version conflict detected for Xamarin.Google.Android.Material - c#

I use the MonoGame 3.8.1.303 template to create my Android project, not the MAUI template. And I set UseMauiEssentials to true in my Android csproj file so that I can use Microsoft.Maui.Essentials.
The problem is that I cannot install the NuGet package Xamarin.Forms 5.0.0.2545 in my Android project because I get this error:
Version conflict detected for Xamarin.Google.Android.Material.
Install/reference Xamarin.Google.Android.Material 1.6.0 directly to
project AndroidProject to resolve this issue. AndroidProject ->
Microsoft.Maui.Dependencies 6.0.548 -> Xamarin.Google.Android.Material
(>= 1.6.0) AndroidProject -> Xamarin.Forms 5.0.0.2545 ->
Xamarin.Google.Android.Material (>= 1.4.0.2 && < 1.5.0).
I'm nor sure if I can use Xamarin.Forms with Microsoft.Maui.Essentials together in my MonoGame Android project.
Should I install Xamarin.Google.Android.Material 1.6.0 without Xamarin.Forms or what does the error message mean?
I use Target Android version 13.0 (API level 33).
EDIT: I have installed Xamarin.Google.Android.Material and after that I have tried to install Xamarin.Forms but then I get a version conflict with another Xamarin package.

I'm nor sure if I can use Xamarin.Forms with Microsoft.Maui.Essentials
together in my MonoGame Android project.
We know that Xamarin.Forms is a nuget for xamarin forms, and Microsoft.Maui.Essentials is a part a maui. So, you cannot install them to the same app.
You should figure out whether your current app is a Xamarin Forms project or a MAUI. Then select the corresponding package according to your needs.

Related

Xamarin PureSocketCluster Multiple Assemblies

After adding the Package PureSocketCluster version 3.1.0 to my Xamarin project, I get the following error when compiling:
.../Projects/HelloWorld/HelloWorld.iOS/CSC: Error CS1703:
Multiple assemblies with equivalent identity have been imported: '.../.nuget/packages/system.reflection.emit/4.3.0/ref/netstandard1.1/System.Reflection.Emit.dll'
and
'/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/System.Reflection.Emit.dll'.
Remove one of the duplicate references. (CS1703) (HelloWorld.iOS)
During the installation, I observed the following warnings:
Detected package downgrade: Xamarin.Forms from 3.4.0.1008975 to 3.1.0.697729. Reference the package directly from the project to select a different version.
HelloWorld.iOS (>= 1.0.0) -> HelloWorld (>= 1.0.0) -> Xamarin.Forms (>= 3.4.0.1008975)
HelloWorld.iOS (>= 1.0.0) -> Xamarin.Forms (>= 3.1.0.697729)
It's a very basic Hello World project, I just wanted to check if the communication with my socketcluster based websocket works in general.
I am using Visual Studio 2017 for Mac 7.6.11.
I'm fairly new to VS, so please don't kill me, if I made a stupid beginner mistake.
The way to resolve the issue is to add this to the iOS project file.
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
Of course you need to make sure the nuget package has been added to the iOS package first.
Here is a similar issue that you can refer.

NuGet package install fails "Package restore failed. Rolling back package changes for <xamarin.android>"

Installing any package fails with this error, updating packages also creates this error. Clearing the NuGet cache files causes this error to change to "access to the path mono.cecil.dll is denied" when trying to install "Xamarin.GooglePlayServices.Ads". Restarting visual studio causes the package restore error to come back.
Versions:
OS: win 10
Visual Studio Information:https://pastebin.com/vnuyZMWk
Xamarin.Forms Project:
Target framework: .NET 2.0
Xamarin.Android project:
Minimum Android Version: 5.0 (API Level 21)
Target Android Version: Use Compile Using SDK version (8.0)
Well after some trial and error I have the solution.
Visual Studio:
Update visual studio https://pastebin.com/GkEeRqg3
Updates Xamarin.Forms and NuGet
Repair visual studio from the "Visual Studio installer"
This Fixes the access denied to *.dll error
Xamarin.Android project:
Set Target Android Version: 8.1 API 27
This makes the packages the require monoandroid81 happy.
Cleaning house
Delete the folder C:\Users\<Your_Name>\AppData\Local\Xamarin`
Not sure if this was necessary but I am documenting anything I did so others can replicate the solution.
Fixing NuGet
Right-click <Project_name>.android --> Set as startup project.
Tools --> NuGet Package Manager --> Package Manager Console
In the console CLI run Update-Package -Reinstall
Why did this happen?
One way or another some of the NuGet packages used in Xamarin.Android used monoandroid81. Even though my solution was set to use 80 some NuGet packages installed were only compatible with 81. This was shown in the NuGet Console.
Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports:
monoandroid81 (MonoAndroid,Version=v8.1)
I faced the same error when I was trying to update the libraries one by one. Then I tried selecting all required libraries and clicked the Update button bellow the search box and it works. I have to tell that these libraries had dependencies between each other.
Here's an example:

getting error while adding some components from nuget in xamarin.android

Getting error while adding some nuget packages to xamarin.android project.
Error-
Could not install package 'Xamarin.GooglePlayServices.Ads 42.1021.1'. 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.
The latest GooglePlayServices packages need Android 7 and above. In order for you to use in Android 6, you will need to use older packages.
Or you can just update the target platform to v7 and above.

Unable to install System.Net.Http in Xamarin portable project

Hello I'm new to Xamarin,
I'm trying to install the System.Net.Http to a Xamarin portable project using NuGet Package Manager.
However, whenever I try to download it I get this error
Could not install package 'System.Net.Http 4.3.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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 every possible version of the package with no use. Could anybody provide some assistance?
Actually the way I managed to solve this problem was weird
I found a referenced assembly called
.NET --> right click View in object browser --> select System.Net.Http --> clicked add reference to the selected project
and the reference is added
Have you tried to install Microsoft.Net.Http? I use it in my PCL Xamarin Forms apps.
This can be resolved by changing the profile number for the PCL project.
Personally, i would untick all the unneeded target frameworks by going to: Project Options -> Build - General - Change Targets.
In my case i have unticked Windows Phone silverlight 8 and the profile number got changed from PCL 4.5 Profile 259 to PCL 4.5 Profile 111 as shown in this screenshot:
After doing so System.Net.Http can be added easily.

Xamarin Forms Deployment Fails After Update

After updating Xamarin from visual studio , Xamarin.Forms application gives this exception when running
System.MissingMethodException: Method Android.Support.V4.Widget.DrawerLayout.AddDrawerListener not found
I did try to update the Nuget Packages, re-install Xamarin for visual studio, re-install android sdk, no thing worked .
How can I solve it ?
Maybe you have updated packages Android.Support.xxxx. Try it:
Uninstall the Xamarin Forms packages and all the android support packackage.
Reinstall just the latest Xamarin Forms Nuget package. Letting it grab the Android support packages. Ignore any Android.Support.xxxx updates.
So I just reproduced your issue and I am sorry that you and other ran into this. It looks like there was an issue in the templates and I am working with the team to quickly resolve this.
To fix:
Simply right click on the android project and select "Manage Nuget Packages"
Go to Updates
Find Xamarin.Android.Support.v7.AppCompat
Select version 23.3.0 from the version picker and hit Install
You additionally will need to install the RecyclerView 23.3.0 NuGet Package. * Go to Browse and search for: Xamarin.Android.Support.v7.RecyclerView and make sure to pick 23.3.0 to install for the correct version
Now do a full clean/rebuild and it should work
This should install the correct versions of everything you need for Android
Optionally, you can select just Xamarin.Forms and update to the latest version on ALL projects and it should update all references that it needs.
Please upgrage your xamarin.forms NuGet package to lastest version.
Xamarin Forms Deployment Fails After Update using Visualstudio
System.MissingMethodException: Method Android.Support.V4.Widget.DrawerLayout.AddDrawerListener not found. below image
am using Visual studio 2015 in android uninstall all packages
next install xamarin.forms package only.
then it is working fine..
Note:upgrade a new versions in Pcl,android (Xamarin.Forms v2.3.1.114)versions and pcl and andriod versions are most be Same

Categories