Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Bump MonoAndroid target to 13.0 #15718

Merged
merged 31 commits into from
May 2, 2023
Merged

Bump MonoAndroid target to 13.0 #15718

merged 31 commits into from
May 2, 2023

Conversation

jfversluis
Copy link
Member

@jfversluis jfversluis commented Mar 29, 2023

This builds Xamarin.Forms with the MonoAndroid 13.0 target. With this we can now use the latest Android(X) packages again and should be more prepared for future Android versions and targets.

However, this change is pretty significant as also a lot of the dependencies got a good bump in their version numbers. Please test your code carefully!

Fixes #15668
Fixes #15678
Fixes #15677
Fixes #15714

Also see xamarin/Essentials#2087

@jfversluis jfversluis marked this pull request as ready for review March 29, 2023 14:12
@jfversluis jfversluis marked this pull request as draft March 29, 2023 14:14
@jfversluis

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@jfversluis

This comment was marked as off-topic.

@azure-pipelines

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@MagicAndre1981

This comment was marked as off-topic.

@siddhant-maurya
Copy link

I am using the latest available version 5.0.0.2578 and I am getting below error. Can someone please update how to fix it!

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(649,5): error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Void Xamarin.Forms.Platform.Android.ShellSearchView/ClipDrawableWrapper::.ctor(Android.Graphics.Drawables.Drawable)' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper

@jfversluis
Copy link
Member Author

@siddhant-maurya look a few comments up, that person had the same issue

@siddhant-maurya
Copy link

@jfversluis Thanks for the quick response. I tried adding Xamarin.AndroidX.AppCompat 1.6.1 but after many attempts I am still getting the same error.

@mos379
Copy link

mos379 commented Apr 16, 2023

@siddhant-maurya you are using the wrong XF version.
try 5.0.0.8491

@siddhant-maurya
Copy link

I am not able to find XF version 5.0.0.8491 in Nuget pkg manager or anywhere else can you please suggest how to get it. Iam using VS 2022 17.5.4

@MagicAndre1981
Copy link
Contributor

add this feed as nuget source: https://aka.ms/forms-prs/index.json to get the nugets for Pull Requests

@siddhant-maurya
Copy link

I have upgraded to XF version 5.0.0.8491 but now it's giving me some other errors -
Any idea what is causing this error?

5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java type javax.inject.Injectis generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Injectgenerated by: Javax.Inject.IInject, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Injectgenerated by: JavaX.Inject.IInject, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java typejavax.inject.Namedis generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Namedgenerated by: Javax.Inject.INamed, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Namedgenerated by: JavaX.Inject.INamed, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java typejavax.inject.Provideris generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Providergenerated by: Javax.Inject.IProvider, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Providergenerated by: JavaX.Inject.IProvider, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java typejavax.inject.Qualifieris generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Qualifiergenerated by: Javax.Inject.IQualifier, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Qualifiergenerated by: JavaX.Inject.IQualifier, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java typejavax.inject.Scopeis generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Scopegenerated by: Javax.Inject.IScope, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Scopegenerated by: JavaX.Inject.IScope, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: The Java typejavax.inject.Singletonis generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Singletongenerated by: Javax.Inject.ISingleton, Scanbot.Xamarin.SDK.Dependencies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 5>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1509,3): error XA4215: javax.inject.Singleton generated by: JavaX.Inject.ISingleton, Xamarin.JavaX.Inject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

@MagicAndre1981
Copy link
Contributor

remove this Scanbot.Xamarin.SDK.Dependencies and only use official AndroidX libs from Xamarin team

@siddhant-maurya
Copy link

got it removed the Scanbot SDK and worked ! Thanks a lot :)

@MagicAndre1981
Copy link
Contributor

nice to hear this and build is green again 🥳 @jfversluis

@jfversluis
Copy link
Member Author

Yeah it seems like LiveData 2.6.1 is causing issues, so I think I will go with this for now

@MagicAndre1981
Copy link
Contributor

ok, I tested 5.0.0.8503 and for me it works and I only get the now expected LiveData out of range warning

@jfversluis
Copy link
Member Author

It's weird that it let's you install the latest version though because I limit it through the nuspec. Is that not enforced anymore? Did that change?

@MagicAndre1981
Copy link
Contributor

I don't configure that warnings are treated as errors, so this works.

@MagicAndre1981
Copy link
Contributor

I created a complete new app in VS2022 without any additional androidx references, updated to 5.0.0.8503 and see those warnings:

Warning	NU1605	Detected package downgrade: Xamarin.AndroidX.CustomView from 1.1.0.14 to 1.1.0.7. Reference the package directly from the project to select a different version. 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.AppCompat 1.6.0 -> Xamarin.AndroidX.Fragment 1.5.5 -> Xamarin.AndroidX.ViewPager 1.0.0.15 -> Xamarin.AndroidX.CustomView (>= 1.1.0.14) 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.CustomView (>= 1.1.0.7 && < 1.2.0)	XFDemoApp.Android	
Warning	NU1605	Detected package downgrade: Xamarin.AndroidX.Core from 1.9.0.1 to 1.6.0.1. Reference the package directly from the project to select a different version. 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.AppCompat 1.6.0 -> Xamarin.AndroidX.Core (>= 1.9.0.1) 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.Core (>= 1.6.0.1 && < 2.0.0)		
Warning	NU1605	Detected package downgrade: Xamarin.AndroidX.CustomView from 1.1.0.14 to 1.1.0.7. Reference the package directly from the project to select a different version. 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.AppCompat 1.6.0 -> Xamarin.AndroidX.DrawerLayout 1.1.1.10 -> Xamarin.AndroidX.CustomView (>= 1.1.0.14) 
 XFDemoApp.Android -> Xamarin.Forms 5.0.0.8503 -> Xamarin.AndroidX.CustomView (>= 1.1.0.7 && < 1.2.0)

@jfversluis
Copy link
Member Author

Hm yeah I probably need to update the templates as well to use this new version directly. And maybe some blog post or something to explain what is going on here 😅

@MagicAndre1981
Copy link
Contributor

yes, this is a breaking change that should be tested and documented well.

A bit offtopic, maybe also retarget Essentials to 13.0 to match the new XF version.

@jfversluis jfversluis merged commit 21f07e9 into 5.0.0 May 2, 2023
10 checks passed
5.0.0 SR15 automation moved this from To Do to Done May 2, 2023
@jfversluis jfversluis deleted the monoandroid13 branch May 2, 2023 11:19
@cncb-gh
Copy link

cncb-gh commented May 20, 2023

How does one get this before it makes its way to NuGet?

@MagicAndre1981
Copy link
Contributor

How does one get this before it makes its way to NuGet?

there are preview nugets packages on nuget.org

@MitchBomcanhao
Copy link

@jfversluis when are we to expect a release version that includes these changes? the deadline for app submissions is looming...

@MitchBomcanhao
Copy link

bump @jfversluis @jamesmontemagno

@MitchBomcanhao
Copy link

hello? @jfversluis @jamesmontemagno

@MagicAndre1981
Copy link
Contributor

I suspect it takes some time for 3rd party control vendors to update their libs as they also need to rebuild their controls for MAUI. Syncfusion is known to always target old XF / MAUI versions and I guess they may need some time to test their controls against new AndroidX libs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.