question

ShantimohanElchuri-8757 avatar image
0 Votes"
ShantimohanElchuri-8757 asked ·

Xamarin Android Support Collection errors after updating to Xamarin.Forms 5.0

Just today I updated my NuGet packages in a project. That also updated Xamarin.Forms to version 5.0. After the update the build complained that the minimum Android Target Version should be 10.0. So I changed it in the project properties. Then I got the following error:

Error Could not find 2 Android X assemblies, make sure to install the following NuGet packages:
- Xamarin.AndroidX.MediaRouter
- Xamarin.AndroidX.Palette
You can also copy-and-paste the following snippet into your .csproj file:
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />

So I tried to install the Xamarin.AndroidX.MediaTrouter NuGet package. The install rolled back with the following error:

Error NU1107 Version conflict detected for Xamarin.Android.Support.Collections. Install/reference Xamarin.Android.Support.Collections 28.0.0.3 directly to project ToDoPlus.Android to resolve this issue.
ToDoPlus.Android -> Xamarin.Android.Support.v7.MediaRouter 28.0.0.3 -> Xamarin.Android.Support.Media.Compat 28.0.0.3 -> Xamarin.Android.Support.VersionedParcelable 28.0.0.3 -> Xamarin.Android.Support.Collections (= 28.0.0.3)
ToDoPlus.Android -> Xamarin.Auth 1.7.0 -> Xamarin.Android.Support.CustomTabs 28.0.0.1 -> Xamarin.Android.Support.Collections (= 28.0.0.1).


Then I tried to install Xamarin.AndroidX.Palette NuGet package. This install also rolled back with the following error:

Error NU1107 Version conflict detected for Xamarin.Android.Support.Collections. Install/reference Xamarin.Android.Support.Collections 28.0.0.3 directly to project ToDoPlus.Android to resolve this issue.
ToDoPlus.Android -> Xamarin.Android.Support.v7.MediaRouter 28.0.0.3 -> Xamarin.Android.Support.Media.Compat 28.0.0.3 -> Xamarin.Android.Support.VersionedParcelable 28.0.0.3 -> Xamarin.Android.Support.Collections (= 28.0.0.3)
ToDoPlus.Android -> Xamarin.Auth 1.7.0 -> Xamarin.Android.Support.CustomTabs 28.0.0.1 -> Xamarin.Android.Support.Collections (= 28.0.0.1).


So now my project doesn't build. Shall I rollback to previous version of Xamarin.Forms or remove the support collection ver 28.0.0.1?



dotnet-xamarinformsdotnet-android
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I think it depends from the "starting point". Which is the current XF version? Do you use VS2017 or 2019? Are you using PCL on NET STANDARD?

0 Votes 0 ·

So I tried to install the Xamarin.AndroidX.MediaTrouter NuGet package. The install rolled back with the following error:

Did you install the Xamarin.Android.Support library in the Android platform? Xamarin.Forms 5.0 requires to install the AndroidX (Android 10.0) platform to the development environment, please uninstall these support libraries and install AndroidX libraries instead.

What's the version of the VS on your pc? It the above doesn't work, try to update the lastest statable version and test again.

Here is the related tutorial you could refer to: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/troubleshooting/questions/forms5-migration#android

0 Votes 0 ·
ShantimohanElchuri-8757 avatar image
0 Votes"
ShantimohanElchuri-8757 answered ·

@JarvanZhang-MSFT I tried to follow the doc you linked above. But I don't have the Android Support libs mentioned in it. I have the following libs installed:

Xamarin.Android.Support.Design
Xamarin.Android.Support.v4
Xamarin.Android.Support.v7.AppCompat
Xamarin.Android.Support.v7.CardView
Xamarin.Android.Support.v7.MediaRouter

Anyway as I was getting error on the MediaRouter, I removed Xamarin.Android.Support.v7.MediaRouter and tried to install Xamarin.AndroidX.MediaRouter. But it rolled back with the following message in Output window:

NU1107: Version conflict detected for Xamarin.Android.Support.Collections. Install/reference Xamarin.Android.Support.Collections 28.0.0.3 directly to project ToDoPlus.Android to resolve this issue.
ToDoPlus.Android -> Xamarin.Android.Support.v4 28.0.0.3 -> Xamarin.Android.Support.Media.Compat 28.0.0.3 -> Xamarin.Android.Support.VersionedParcelable 28.0.0.3 -> Xamarin.Android.Support.Collections (= 28.0.0.3)
ToDoPlus.Android -> Xamarin.Auth 1.7.0 -> Xamarin.Android.Support.CustomTabs 28.0.0.1 -> Xamarin.Android.Support.Collections (= 28.0.0.1).


This also mentions about Xamarin.Auth 1.7.0 which is also installed in my project. Do I have to remove this also? Then what is the replacement for it?

I updated my VS2019 to v16.8.4 which was available today only. Also installed Android SDK Build Tools 29.0.3. It appears migrating to XF 5.0 is quite messy.

· 7 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have the following libs installed

The Xamarin.Android.Support libraries don't support to work on Android 10, try uninstall them. How did you use these libraries? It dosn't require to install them on Android in a Xamarin.Forms project. If the code requires to install some packges, please install AndroidX libraries instead.

0 Votes 0 ·

@JarvanZhang-MSFT I have deleted all the NuGet packages mentioned above and installed Xamarin.AndroidX.Collection v1.1.0.6. Now I get the following error messages:

Error Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.
Error Assembly 'Xamarin.Android.Support.v4' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.

Why is it still referencing Xamarin.Android.Support.v4?

0 Votes 0 ·
alessandrocaliaro avatar image alessandrocaliaro ShantimohanElchuri-8757 ·

have you deleted ALL bin and obj folders?

0 Votes 0 ·
JarvanZhang-MSFT avatar image JarvanZhang-MSFT ShantimohanElchuri-8757 ·

Make sure the namespaces have been updated with the AndroidX libraries. And check that the nuget installed in the project references the Android.Support package.

0 Votes 0 ·

How do I check if a NuGet package is referencing Android.Support pakage?

0 Votes 0 ·
Show more comments

@alessandrocaliaro Yes, I did delete them after your suggestion. But still same errors are occuring.

0 Votes 0 ·
alessandrocaliaro avatar image
0 Votes"
alessandrocaliaro answered ·

I suggest to create a new project with the same name, update it to XF 5 and copy all your code inside it

· 12 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@alessandrocaliaro That's not a better solution. What if an app is already published? By creating a new solution the GUID of the app will change and the App/Play stores will consider it as a new app rather than an update version. Also I have large amount of data fed into the app on my dev phone and haven't tested the backup procedures. So creating a new solution will have all the data porting issues.

There should have been seamless upgrade to new version of XF. Even though Android X is a major upgrade, the libraries should have been bug free. Creating a new solution and porting the code is not a solution. I have been developing this app for 2 years and don't even remember in what sequence I added features.

@JarvanZhang-MSFT Do you have any solution?

0 Votes 0 ·
alessandrocaliaro avatar image alessandrocaliaro ShantimohanElchuri-8757 ·

What are you saying? You can create your new project keeping the files and the applicationid and you have a new app that you can publish to the store as the old app. You have only to copy and paste your files in the new project and it works. I have already done this and I had no problems at all

0 Votes 0 ·

How do you keep the app id same? Once I tried it long back but it didn't work. Do you have a reference.

Also my project contains 12 models, 36 value converters, 35 views and 18 interface and utility classes. May be it is small compared to many projects. But for me porting all these to a new solution and debugging it appears to be not a small thing. But the upgrade path to XF 5.0 is not clear and straight forwards like earlier.

Also I am using some 3rd party libs. I don't know if they are all compatible with XF 5.0. I am waiting for a word from them too. If they are not compatible right away then I may have to wait for some more time before I finalize the update to XF 5.0. If I remember well, I think we had similar issue when moving from XF 2.x to 3.0 too.

0 Votes 0 ·

You have not yet told me how to keep the app id same in a new solution?

0 Votes 0 ·

OK. I created a new app, set it to Xamarin.Forms 5.0, Set the Android Project properties Compile using Android version (Target Framework) and Target Android Version to 10.0.

Started installing one by one needed NuGet packages and running the sample app after every download.

After downloading Xamarin.Auth, I got the following error on running the app:

Could not find file 'E:\XPA Samples\XF5_App1\XF5_App1\XF5_App1.Android\obj\Debug\100\android\assets\Xamarin.Auth.dll.mdb'.

0 Votes 0 ·
JarvanZhang-MSFT avatar image JarvanZhang-MSFT ShantimohanElchuri-8757 ·

In Xamarin.Forms 5.0, AndroidX is now the default for Xamarin.Forms. Xamarin.Auth doesn't support to work with AndroidX, try using Essentials.WebAuthenticator to achieve the authentication.

0 Votes 0 ·

That's a good suggestion.

I am using Xamarin.Auth.OAuth2Authenticator() for authenticating using the methods detailed in this article for using Google Drive API access. Is there any equivalent post using XamarinEssentials.WebAuthentictor()?

Of course it may take some time for me to do that but I am looking for some quick solutions. Also this does involve major code revision which may delay my app's next release.


0 Votes 0 ·
Show more comments