1iveowl / Plugin.SegmentedControl

MIT License
170 stars 29 forks source link

Upgrading to 5.2+ results in Android compile time errors #102

Open mrbelk opened 4 years ago

mrbelk commented 4 years ago

I have updated my android platform project to use AndroidX, targeting API29. If I reference 5.0.2 of this library, everything builds and runs without any problem. Once I update to any version > 5.2, I get a number of compile error pairs similar to this:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error XA0121: Assembly 'Xamarin.Android.Support.Animated.Vector.Drawable' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author. (XA0121) (goRoamPOD.Android)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error XA0121: Assembly 'Xamarin.Android.Support.Animated.Vector.Drawable' is using '[assembly: Android.IncludeAndroidResourcesFromAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author. (XA0121) (goRoamPOD.Android)

There is clearly some dependency that is not right here. When I update your package to the latest version from 5.0.2, it pulls in a few other Xamarin.AndroidX packages.

What am I doing wrong?

Thanks, Matthew

mrbelk commented 3 years ago

Just to bump this. I forked the code to see if I could get any better compiler messages. I updated the target android framework of my project to API30, and consolidated all of the xamarin.forms and androidx nugets between the control's platform project and my application. Now, I can build in DEBUG mode just fine. But when I switch to release, with the linker set to "Link SDK Assemblies," I get this compiler error:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(5,5): Error XALNK7000: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Support.V4.App.NotificationCompat/BuilderExtender' (defined in assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. 
---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.V4.App.NotificationCompat/BuilderExtender  
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType 
(Mono.Cecil.TypeReference reference) [0x00013] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x0002c] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00060] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in <3e53085892e04b628169d0ea2d9ff8b6>:0 
at Mono.Linker.Steps.MarkStep.MarkField (Mono.Cecil.FieldDefinition field) [0x00011] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Steps.MarkStep.MarkEntireType (Mono.Cecil.TypeDefinition type) [0x000bd] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Steps.MarkStep.MarkEntireType (Mono.Cecil.TypeDefinition type) [0x0001e] in <3e53085892e04b628169d0ea2d9ff8b6>:0  at Mono.Linker.Steps.MarkStep.MarkEntireAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x0003a] in <3e53085892e04b628169d0ea2d9ff8b6>:0  at Mono.Linker.Steps.MarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00045] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Steps.MarkStep.Initialize () [0x00014] in <3e53085892e04b628169d0ea2d9ff8b6>:0  at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00007] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at MonoDroid.Tuner.MonoDroidMarkStep.Process (Mono.Linker.LinkContext context) [0x0000b] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Pipeline.ProcessStep (Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) [0x0000d] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0000f] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x001dd] in <3e53085892e04b628169d0ea2d9ff8b6>:0   
--- End of inner exception stack trace --- 
at Java.Interop.Tools.Diagnostics.Diagnostic.Error (System.Int32 code, System.Exception innerException, System.String message, System.Object[] args) [0x00000] in /Users/builder/azdo/_work/451/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics/Diagnostic.cs:166  
at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x00276] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Xamarin.Android.Tasks.LinkAssemblies.RunTask () [0x0001b] in <3e53085892e04b628169d0ea2d9ff8b6>:0  
at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in <3e53085892e04b628169d0ea2d9ff8b6>:0  (XALNK7000) (goRoamPOD.Android)

If I set the linker to "Don't link" in RELEASE mode, my platform project builds just fine. Of course, I couldn't reproduce the behavior with the test project in the solution.