Reputation: 1
I have written a MAUI app based on the documentation sample "Xaminals". It compiles fine but at initialization in the Android emulator I get the following exception:
Android.Views.InflateException
Message=Binary XML file line #1 in com.companyname.shvn_guide:layout/flyoutcontent: Binary XML file line #1 in com.companyname.shvn_guide:layout/flyoutcontent: Error inflating class com.google.android.material.appbar.AppBarLayout
Stack trace
0xFFFFFFFFFFFFFFFF in Android.Runtime.JNIEnv.monodroid_debugger_unhandled_exception C# 0x1A in Android.Runtime.JNINativeWrapper.unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5 C# 0x1E in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:122,26 C# 0x17 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw C# 0x69 in Java.Interop.JniEnvironment.InstanceMethods.CallObjectMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:11524,5 C# 0x3E in Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:867,7 C# 0x4B in Android.Views.LayoutInflater.Inflate at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Views.LayoutInflater.cs:661,5 C# 0x2B in Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutTemplatedContentRenderer.LoadView at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutTemplatedContentRenderer.cs:78,4 C# 0x2B in Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutTemplatedContentRenderer..ctor at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutTemplatedContentRenderer.cs:60,4 C# 0x1 in Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.CreateShellFlyoutContentRenderer at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellRenderer.cs:144,4 C# 0x1 in Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.Microsoft.Maui.Controls.Platform.Compatibility.IShellContext.CreateShellFlyoutContentRenderer at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellRenderer.cs:49,4 C# 0x1C in Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.AddFlyoutContentToLayoutIfNeeded at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRenderer.cs:249,5 C# 0x68 in Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.AttachFlyout at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRenderer.cs:231,5 C# 0x3 in Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRenderer.Microsoft.Maui.Controls.Platform.Compatibility.IShellFlyoutRenderer.AttachFlyout at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRenderer.cs:64,4 C# 0x55 in Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.OnElementSet at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellRenderer.cs:211,4 C# 0x1B in Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.SetVirtualView at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellRenderer.cs:194,4 C# 0x7 in Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.Microsoft.Maui.IElementHandler.SetVirtualView at D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellRenderer.cs:302,4 C# 0x8B in Microsoft.Maui.Controls.Element.SetHandler at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:69,6 C# 0x2 in Microsoft.Maui.Controls.Element.set_Handler at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:19,11 C# 0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\VisualElement\VisualElement.Impl.cs:305,5 C# 0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler at D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:96,4 C# 0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform at D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127,4 C# 0x5F in Microsoft.Maui.Platform.ContainerView.SetView at D:\a_work\1\s\src\Core\src\Platform\Android\ContainerView.cs:72,5 C# 0x3 in Microsoft.Maui.Platform.ContainerView.set_CurrentView at D:\a_work\1\s\src\Core\src\Platform\Android\ContainerView.cs:51,11 C# 0x8 in Microsoft.Maui.Platform.ElementExtensions.ToContainerView at D:\a_work\1\s\src\Core\src\Platform\Android\ElementExtensions.cs:11,4 C# 0x1F in Microsoft.Maui.Platform.NavigationRootManager.Connect at D:\a_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationRootManager.cs:56,5 C# 0x26 in Microsoft.Maui.Handlers.WindowHandler.CreateRootViewFromContent at D:\a_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:79,4 C# 0x15 in Microsoft.Maui.Handlers.WindowHandler.MapContent at D:\a_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:24,4 C# 0x21 in Microsoft.Maui.PropertyMapper<Microsoft.Maui.IWindow,Microsoft.Maui.Handlers.IWindowHandler>. at D:\a_work\1\s\src\Core\src\PropertyMapper.cs:172,6 C# 0x17 in Microsoft.Maui.PropertyMapper.UpdatePropertyCore at D:\a_work\1\s\src\Core\src\PropertyMapper.cs:47,4 C# 0x1D in Microsoft.Maui.PropertyMapper.UpdateProperties at D:\a_work\1\s\src\Core\src\PropertyMapper.cs:82,5 C# 0xCB in Microsoft.Maui.Handlers.ElementHandler.SetVirtualView at D:\a_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:79,4 C# 0x8B in Microsoft.Maui.Controls.Element.SetHandler at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:69,6 C# 0x2 in Microsoft.Maui.Controls.Element.set_Handler at D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:19,11 C# 0xA2 in Microsoft.Maui.Platform.ElementExtensions.SetHandler at D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:156,4 C# 0x3 in Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler at D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:166,4 C# 0x79 in Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow at D:\a_work\1\s\src\Core\src\Platform\Android\ApplicationExtensions.cs:46,4 C# 0x54 in Microsoft.Maui.MauiAppCompatActivity.OnCreate at D:\a_work\1\s\src\Core\src\Platform\Android\MauiAppCompatActivity.cs:32,4 C# 0x11 in Android.App.Activity.n_OnCreate_Landroid_os_Bundle at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.App.Activity.cs:2816,4 C# 0x9 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:121,5 C#
Environment
Windows 10 Pro 19045.3324 16 GB RAM Visual Studio Community Ed. 17.7.3 .NET 7.0 Emulator Pixel 5 API - 33 (Android 13 - API 33)
The error message and stack trace above is all info I get from Visual Studio. I have found no relevant info on Internet. A similar app written for Xamarin did NOT cast this exception. I would appreciate any info on this problem.
Added sept 14: The exception is thrown in the function InitializeComponent() in the App constructor (in App.xaml.cs)
Upvotes: 0
Views: 664
Reputation: 4332
I have written a MAUI app based on the documentation sample "Xaminals". A similar app written for Xamarin did NOT cast this exception.
You mean that you made a MAUI app with reference to this: Xaminals (xamarin-forms-samples)? If so, You need to notice that Xamarin's project is a bit different from MAUI's. For more info about it, you can refer to the official doc: Migrate from Xamarin.
You can directly use this code sample:Xaminals (maui-samples). I tested it, and it works well.
Upvotes: 0