-
Notifications
You must be signed in to change notification settings - Fork 568
Description
Android framework version
net10.0-android
Affected platform version
VS 2026 18.3.1, Dotnet SDK 10.0.103, maui-android 10.0.103
Description
When the SKCanvasView from the SkiaSharp.Views.Maui.Controls package is included in a content page, Android NativeAOT builds crash when initialising the view.
A build warning is produced during the build suggesting that the _Microsoft.Android.Resources.Designer.dll library hasn't been linked.
Steps to Reproduce
Repro project at:
https://github.com/james-allison/dotnet-repros/tree/main/NativeAOT-Android-SkiaSharp
This is the basic MAUI sample app with the addition of the SkiaSharp.Views.Maui.Controls nuget package (v3.119.2).
A SKCanvasView control has been added to the MainPage.xaml.
The android debug config (and CoreCLR release config) builds and runs fine.
Building the android NativeAOT Release config will produce a warning:
1> ILC: Method '[SkiaSharp.Views.Android]SkiaSharp.Views.Android.SKCanvasView.Initialize(IAttributeSet)' will always throw because: Failed to load assembly '_Microsoft.Android.Resource.Designer'
The App then crashes immediately on initialising the MainPage.
Did you find any workaround?
None.
Relevant log output
During NativeAOT build:
1> ILC: Method '[SkiaSharp.Views.Android]SkiaSharp.Views.Android.SKCanvasView.Initialize(IAttributeSet)' will always throw because: Failed to load assembly '_Microsoft.Android.Resource.Designer'
When the app is run, it crashes immediately with the following exception:
System.Exception: CurrentDomainOnUnhandledException
---\u003E System.IO.FileNotFoundException: IO_FileNotFound_FileName, _Microsoft.Android.Resource.Designer
IO_FileName_Name, _Microsoft.Android.Resource.Designer
at Internal.Runtime.TypeLoaderExceptionHelper.CreateFileNotFoundException(ExceptionStringID, String) \u002B 0x50
at SkiaSharp.Views.Android.SKCanvasView.Initialize(IAttributeSet) \u002B 0x18
at SkiaSharp.Views.Maui.Handlers.SKCanvasViewHandler.CreatePlatformView() \u002B 0x38
at Microsoft.Maui.Handlers.ViewHandler\u00602.OnCreatePlatformView() \u002B 0x58
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement) \u002B 0x58
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler) \u002B 0x124
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement, IMauiContext) \u002B 0x160
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement, IMauiContext) \u002B 0x2c
at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView) \u002B 0xc8
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler) \u002B 0x124
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement, IMauiContext) \u002B 0x160
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement, IMauiContext) \u002B 0x2c
at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView) \u002B 0xc8
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler) \u002B 0x124
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement, IMauiContext) \u002B 0x160
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement, IMauiContext) \u002B 0x2c
at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler) \u002B 0xb4
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler, IElement) \u002B 0x8c
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement) \u002B 0x174
at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView) \u002B 0x18
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler) \u002B 0x124
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement, IMauiContext) \u002B 0x160
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement, IMauiContext) \u002B 0x2c
at Microsoft.Maui.Platform.NavigationViewFragment.OnCreateView(LayoutInflater, ViewGroup, Bundle) \u002B 0x9c
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) \u002B 0x260