[Bug] CommunityToolkit samples app is broken on Android
Is there an existing issue for this?
- [x] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
Exception trying to navigate to any page in the sample app. System.NotSupportedException Message=Unable to activate instance of type Microsoft.Maui.Controls.Platform.Compatibility.ShellItemRenderer from native handle 0x7fda730da0 (key_handle 0x41e2660).
Expected Behavior
No exceptions
Steps To Reproduce
Build the sample app. Debug and try to navigate to any of the pages.
Link to public reproduction project repository
https://github.com/CommunityToolkit/Maui
Environment
- .NET MAUI CommunityToolkit: main branch
- OS: Windows 11
- .NET MAUI: 9.0.102
- Visual Studio 17.12.4
Anything else?
No response
It's a known issue fixed in the latest .NET MAUI workload.
-
Download + install the latest version of .NET: https://dotnet.microsoft.com/en-us/download
-
After updating to the latest version of .NET, open the a Terminal window and enter the following command:
- On macOS:
sudo dotnet workload install maui;sudo dotnet workload update - On Windows:
dotnet workload install maui;dotnet workload update
Thanks!
This appears to be an issue caused by a mismatch between net9.0-android workload and the Microsoft.Maui.Controls NuGet Package.
For now, the workaround is to set options.SetShouldUseStatusBarBehaviorOnAndroidModalPage(false);
.UseMauiCommunityToolkit(static options =>
{
options.SetShouldEnableSnackbarOnWindows(true);
options.SetShouldUseStatusBarBehaviorOnAndroidModalPage(false);
})
@jfversluis Is this a known issue on the .NET MAUI team? It's nearly identical to the same issue that was resolved in SR3; here's the Discord link to our conversation about it.