Skip to content

Incompatible ButtonHandler when embedding MAUI page in .NET Android-project #7549

@andreas-nesheim

Description

@andreas-nesheim

Description

I'm testing out embedding MAUI pages into a new .NET 6 Android-project using this guide. When I try to embed a page that contains a Button control it crashes with the following exception: Microsoft.Maui.Platform.ToPlatformException: 'Microsoft.Maui.Handlers.ButtonHandler found for Microsoft.Maui.Controls.Button is incompatible'. This happens at the following statement:

var view = myMauiPage.ToPlatform(mauiContext);

When I test the same thing on a .NET 6 iOS-project, it works fine.

Steps to Reproduce

  1. Create a File -> New "Android application" (.NET 6 template)
  2. Follow the guide to enable MAUI embedding in the Android project.
  3. Add a MAUI page to the project and add a Button to the page
  4. Try to call .ToPlatform(context) on the new page

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

Had to comment out the Button.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions