xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] [Android] Upgrading 5.0.0.2578 to 5.0.0.2612 error XA4212 #15817

Closed GUOLDEV closed 9 months ago

GUOLDEV commented 9 months ago

Description

Error error XA4212: Type AndroidX.MediaRouter.App.MediaRouteDynamicControllerDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported. Error error XA4212: Type AndroidX.MediaRouter.App.MediaRouteChooserDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported.
Error error XA4212: Type AndroidX.AppCompat.App.AppCompatDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported.
Error error XA4212: Type AndroidX.MediaRouter.App.MediaRouteDynamicChooserDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported. Error error XA4212: Type AndroidX.MediaRouter.App.MediaRouteControllerDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported. Error error XA4212: Type Google.Android.Material.BottomSheet.BottomSheetDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported. Error error XA4212: Type AndroidX.AppCompat.App.AlertDialog implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported.

Basic Information

Environment

Microsoft Visual Studio Professional 2022 Version 17.7.4 VisualStudio.17.Release/17.7.4+34031.279 Microsoft .NET Framework Version 4.8.04084

Installed Version: Professional

ASP.NET and Web Tools 17.7.273.65229 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.7.273.65229 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.7.273.65229 Azure Functions and Web Jobs Tools

C# Tools 4.7.0-3.23416.8+43b0b05cc4f492fd5de00f6f6717409091df8daa C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Conveyor by Keyoti 1.0 Allows you to access your web applications from other machines, even if hosted on the development web server.

Extensibility Message Bus 1.4.34 (main@d5ab18b) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.7.27 (547ea6f) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.7.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core) 17.7.3.2333001+0ab18affdf2a37647768d0e25f5f021bee6257a1 Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.7.10.1 Microsoft SQL Server Data Tools

StylerPackage Extension 1.0 StylerPackage Visual Stuido Extension Detailed Info

TypeScript Tools 17.0.20829.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.7.0-3.23416.8+43b0b05cc4f492fd5de00f6f6717409091df8daa Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.7.0-beta.23314.10+e612cf93b989503c89e3a5830090062b7ab5e143 Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info

Xamarin 17.7.0.216 (d17-7@133ddef) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.7.3.9 (remotes/origin/d17-7@796d191def) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.7.21 (150ec9f) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.2.1.2 (d17-5/a8a26c7) Xamarin.Android Reference Assemblies and MSBuild support. Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Xamarin.iOS and Xamarin.Mac SDK 16.4.0.15 (8c3876d5e) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

jfversluis commented 9 months ago

Make sure to update all your dependencies and do a good clean and rebuild, also target Android 13 as is outlined here.

jfversluis commented 9 months ago

No response for 3 weeks so assuming that was it 😄

MagicAndre1981 commented 8 months ago

I get similar issue after updating some AndroidX packages:

error XA4212: Type AndroidX.DataBinding.ObservableArrayMap implements Android.Runtime.IJavaObject but does not inherit Java.Lang.Object or Java.Lang.Throwable. This is not supported.

and I "solved" it by adding this to my .csproj:

<PropertyGroup>
    <AndroidErrorOnCustomJavaObject>false</AndroidErrorOnCustomJavaObject>
</PropertyGroup>

By default this value is true and triggers the error. Maybe he also found this workaround @jfversluis

And I also get warnings about version outside of dependency constraint again:

NU1608: Detected package version outside of dependency constraint: Xamarin.Forms 5.0.0.2612 requires Xamarin.AndroidX.Lifecycle.LiveData (>= 2.3.1.1 && <= 2.6.1.1) but version Xamarin.AndroidX.Lifecycle.LiveData 2.6.2.1 was resolved.
NU1608: Detected package version outside of dependency constraint: Xamarin.Forms 5.0.0.2612 requires Xamarin.Google.Android.Material (>= 1.4.0.2 && < 1.9.0) but version Xamarin.Google.Android.Material 1.10.0 was resolved.
NU1608: Detected package version outside of dependency constraint: Xamarin.Forms 5.0.0.2612 requires Xamarin.AndroidX.Browser (>= 1.3.0.6 && < 1.6.0) but version Xamarin.AndroidX.Browser 1.6.0.1 was resolved.
NU1608: Detected package version outside of dependency constraint: Xamarin.Forms 5.0.0.2612 requires Xamarin.AndroidX.Navigation.UI (>= 2.3.5.1 && < 2.6.0) but version Xamarin.AndroidX.Navigation.UI 2.7.4 was resolved.