Skip to content

Java.Lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponent. #13356

@JaneySprings

Description

@JaneySprings

Description

Hello. I'm trying to open a popup on button click. But something went wrong and I get the following exception:
Screenshot 2023-02-15 at 16 10 15
Screenshot 2023-02-15 at 16 11 29

Steps to Reproduce

  1. Run the application from the repository.
  2. Click the 'Show me' button on the MainPage and you can see the exception.

if you replace the Button with the Label, the application works fine.
https://github.com/JaneySprings/MauiAndroidMaterialBug/blob/438e4b223e6e0ae9b9515ce6e791281edba402b8/MainPage.xaml.cs#L14

Link to public reproduction project repository

https://github.com/JaneySprings/MauiAndroidMaterialBug

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

29

Did you find any workaround?

If you replace the Button with a Label, it will work.

Relevant log output

[ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
F/mono-rt :    at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 12324
F/mono-rt :    at Java.Interop.JniPeerMembers.JniInstanceMethods.FinishCreateInstance(String constructorSignature, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:line 174
F/mono-rt :    at Google.Android.Material.Button.MaterialButton..ctor(Context context) in /Users/runner/work/1/s/generated/com.google.android.material.material/obj/Release/net6.0-android/generated/src/Google.Android.Material.Button.MaterialButton.cs:line 385
F/mono-rt :    at Microsoft.Maui.Platform.MauiMaterialButton..ctor(Context context) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiMaterialButton.cs:line 13
F/mono-rt :    at Microsoft.Maui.Handlers.ButtonHandler.CreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\Button\ButtonHandler.Android.cs:line 27
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IButton, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Google.Android.Material.Button.MaterialButton, Xamarin.Google.Android.Material, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 72
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 123
F/mono-rt :    at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 101
F/mono-rt :    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 50
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler.SetVirtualView(IElement element) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 129
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IButton, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Google.Android.Material.Button.MaterialButton, Xamarin.Google.Android.Material, 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
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IButton, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Google.Android.Material.Button.MaterialButton, Xamarin.Google.Android.Material, 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
F/mono-rt :    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 69
F/mono-rt :    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 19
F/mono-rt :    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\VisualElement\VisualElement.Impl.cs:line 303
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
F/mono-rt :    at mauiTemplate.MainPage.Button_Clicked(Object sender, EventArgs e) in /Users/nromanov/Work/mauiTemplate/MainPage.xaml.cs:line 15

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions