Repository navigation
Description
Description
It appears by default, .NET 8 P6 is targeting Android api 34 which breaks quite a few 3rd party libraries (https://github.com/sswi/AcrylicView.MAUI/tree/master , https://github.com/syncfusion/maui-demos for example) who are yet to target .NET 8 and Android 34. Im seeing various exception such as, class not found exception.
Is there a way to lower the Android target in .NET8 P6 or we are forced to wait while Android 34 gos GA, then library authors update their library and then we, the MAUI mortals get to taste .NET 8 ?
Steps to Reproduce
N/A
Link to public reproduction project repository
Repro attached:
Preview6.zip
Build and deploy to an emulator running on API 29 (same goes for emulator running on API 34).
Log for Acrylic library:
log.txt
Log for Sf library:
log2.txt
Version with bug
8.0.0-preview.6.8686
Last version that worked well
7.0.52
Affected platforms
Android
Affected platform versions
Android 34
Did you find any workaround?
NOPE
Relevant log output
For Acrylic library I see:
System.MissingMethodException: Method not found: Microsoft.Maui.Graphics.Size Microsoft.Maui.IContentView.CrossPlatformMeasure(double,double)
at Microsoft.Maui.Handlers.ViewHandler`2[[Xe.AcrylicView.Controls.IAcrylicView, Xe.AcrylicView, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null],[Android.Widget.FrameLayout, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].OnCreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 72
at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 134
at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 101
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 50
at Microsoft.Maui.Handlers.ViewHandler`2[[Xe.AcrylicView.Controls.IAcrylicView, Xe.AcrylicView, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null],[Android.Widget.FrameLayout, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
at Microsoft.Maui.Handlers.ViewHandler`2[[Xe.AcrylicView.Controls.IAcrylicView, Xe.AcrylicView, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null],[Android.Widget.FrameLayout, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 831
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 781
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 42
at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 47
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 79
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 26
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 831
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 781
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ViewExtensions.cs:line 43
at Microsoft.Maui.Controls.Platform.Compatibility.ShellContentFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellContentFragment.cs:line 145
at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 2031
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 352
For SF library I see:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeLoadException: Parent class vtable failed to initialize, due to: Could not load list of method overrides due to Method not found: Microsoft.Maui.Graphics.Size Microsoft.Maui.IContentView.CrossPlatformMeasure(double,double) assembly:/data/data/com.companyname.preview6/files/.__override__/Syncfusion.Maui.Charts.dll type:ChartBase member:(null)
at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object obj, IntPtr* args)
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\CreateValuesVisitor.cs:line 102
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 159
at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 212
at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 207
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 78
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 53
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 49
at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[SfControlsView](SfControlsView view, Type callingType) in D:\a\_work\1\s\src\Controls\src\Xaml\ViewExtensions.cs:line 37
at Preview6.SfControlsView.InitializeComponent() in /Users/syedhoque/Documents/Repos/Preview6/Preview6/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/SfControlsView.xaml.sg.cs:line 26
at Preview6.SfControlsView..ctor() in /Users/syedhoque/Documents/Repos/Preview6/Preview6/SfControlsView.xaml.cs:line 11
at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object obj, IntPtr* args)
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\MauiContext.cs:line 68
at Microsoft.Maui.Controls.Routing.TypeRouteFactory.GetOrCreate(IServiceProvider services) in D:\a\_work\1\s\src\Controls\src\Core\Routing.cs:line 273
at Microsoft.Maui.Controls.Routing.GetOrCreateContent(String route, IServiceProvider services) in D:\a\_work\1\s\src\Controls\src\Core\Routing.cs:line 162
at Microsoft.Maui.Controls.ShellSection.GetOrCreateFromRoute(String route, ShellRouteParameters queryData, IServiceProvider services, Boolean isLast, Boolean isPopping) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 485
at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 526
at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellNavigationManager.cs:line 197
at Preview6.MainPage.OnSfControl(Object sender, EventArgs e) in /Users/syedhoque/Documents/Repos/Preview6/Preview6/MainPage.xaml.cs:line 19
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 36
at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:line 84
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22
Activity
jonathanpeppers commentedon Jul 14, 2023
To my knowledge, we did not hit any similar problems when .NET 7 moved to API 33 by default.
What are the
class not found exception's you are seeing? Can you cause the crash and share a log viaadb logcat -d > log.txt?Syed-RI commentedon Jul 17, 2023
@jonathanpeppers and @jsuarezruiz added repro and relevant logs. Hope that helps?
jonathanpeppers commentedon Jul 17, 2023
@Syed-RI yes, this looks like an API change in MAUI:
This isn't anything to do with Android API 34?
The API was changed because the old one could introduce memory leaks: #15303
Syed-RI commentedon Jul 17, 2023
@jonathanpeppers Thanks for confirming, but it does breaks the libraries that relies on this right? How to get around this?
[-].NET 8 Preview 6 Android target[/-][+].NET 8 Preview 6 Android crashes with System.MissingMethodException[/+]jonathanpeppers commentedon Jul 17, 2023
@PureWeen @hartez @mattleibow do we have a recommendation for API changes like this?
From what I see, the owner of this library would need to build a preview NuGet package for .NET 8?
https://github.com/sswi/AcrylicView.MAUI/blob/1743fc072967ca5aabb39dc91038bbe53e4da989/AcrylicView/Platforms/iOS/AcrylicViewHandler.cs#L19-L20
Syed-RI commentedon Jul 17, 2023
@jonathanpeppers @jsuarezruiz @PureWeen @mattleibow Hmm more importantly, I think breaking public API changes like this should be handled more gracefully internally at MAUI project. Maybe mark the existing method as
Obsoleteand point people towards the new one? I thought that would be the "de-facto" no?jonathanpeppers commentedon Jul 17, 2023
I don't know how "public" handler APIs are? It might be they have a less strict policy, compared to an API change on
Label.Syed-RI commentedon Jul 17, 2023
Me neither and that was just my assumption as I have not done much due diligence to check the PR referenced above and the source for the library.
Apologies
Reinstate IContentView and ILayout methods
Reinstate IContentView and ILayout methods
Reinstate IContentView and ILayout methods (#16411)
Syed-RI commentedon Aug 1, 2023
Wow that was quick!. Thanks everyone! ❤️
[net8.0] Merge main to net8.0 (#16473)