Android Emulator on MacOS raises an error with MAUI
I'm using my iMac to work a bit faster on my .NET8 MAUI
application and get it ready for all platforms. The project runs perfectly on my Windows 11 laptop. Now, I want to use MacOS because, unfortunately, it is easy to use Visual Studio for Mac because faster and easy to use.
In order to test iOS, MacCatalyst, and Android, I work on my iMac and Visual Studio for Mac (although it is not supported anymore). I created a new emulator for Android.
and then run the emulator.
The application is working on my Windows machine for Windows and Android and on my iMac for MacCtalyst and iOS. Unfortunately, when I run the app on the Android emulator on my iMac, I get this error
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Maui.Controls.Xaml.XamlParseException: No embeddedresource found for PSC.Maui.Components.LanguageDropdown.LanguageDropdown at Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode) in //src/Controls/src/Xaml/CreateValuesVisitor.cs:106 at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in //src/Controls/src/Xaml/XamlNode.cs:189 at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in //src/Controls/src/Xaml/XamlNode.cs:185 at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in //src/Controls/src/Xaml/XamlNode.cs:185 at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in //src/Controls/src/Xaml/XamlNode.cs:242 at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties) in //src/Controls/src/Xaml/XamlLoader.cs:208 at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties) in //src/Controls/src/Xaml/XamlLoader.cs:78 at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties) in //src/Controls/src/Xaml/XamlLoader.cs:53 at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType) in //src/Controls/src/Xaml/XamlLoader.cs:49 at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXamlMainPage in //src/Controls/src/Xaml/ViewExtensions.cs:37 at LanguageDropdownDemo.MainPage.InitializeComponent() in /Users/enrico/Projects/PSC.Maui.Components.LanguageDropdown/LanguageDropdownDemo/obj/Debug/net8.0-android/Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/MainPage.xaml.sg.cs:26 at LanguageDropdownDemo.MainPage..ctor() in /Users/enrico/Projects/PSC.Maui.Components.LanguageDropdown/LanguageDropdownDemo/MainPage.xaml.cs:9 at at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) End of inner exception stack trace --- at at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) at at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions) at at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) at at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at at System.Activator.CreateInstance(Type type, Boolean nonPublic) at at System.Activator.CreateInstance(Type type) at Microsoft.Maui.Controls.ShellContent.<>c__DisplayClass19_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0() in //src/Controls/src/Core/Shell/ShellContent.cs:76 at Microsoft.Maui.Controls.ElementTemplate.CreateContent() in //src/Controls/src/Core/ElementTemplate.cs:86 at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(DataTemplate self, Object item, BindableObject container) in //src/Controls/src/Core/DataTemplateExtensions.cs:23 at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent() in //src/Controls/src/Core/Shell/ShellContent.cs:81 at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in //src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs:124 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: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:363
The same project is working on my Windows machine. I don't understand what the problem is.