Issue 11 - layout/design_layout_snackbar_include: Error inflating class android.widget.Button#13
Merged
HavenDV merged 6 commits intooscoreio:mainfrom Jul 16, 2025
Merged
Conversation
Updated the `Microsoft.Maui.Controls` package version from a variable reference `$(MauiVersion)` to a specific version `9.0.82` in both the `Maui.Android.InAppUpdates.SampleApp.csproj` and `Maui.Android.InAppUpdates.csproj` files.
Updated `Microsoft.Extensions.Logging.Debug` to version `9.0.7` in `Maui.Android.InAppUpdates.SampleApp.csproj`. In `Maui.Android.InAppUpdates.csproj`, incremented versions of several Xamarin.AndroidX and Google Play App Update packages to: - `Xamarin.AndroidX.Activity.Ktx` to `1.10.1.2` - `Xamarin.AndroidX.Collection.Ktx` to `1.5.0.2` - `Xamarin.AndroidX.Fragment.Ktx` to `1.8.8` - `Xamarin.Google.Android.Play.App.Update.Ktx` to `2.1.0.15`
- Modified `ShowShortToast` to include null checks and exception handling. - Refactored `ShowSnackbar` to add fallback to toast and improved error handling for theme-related exceptions. - Introduced `FallbackToToastWithAction` and `HandleSnackbarFailure` for better organization and readability. - Added `IsThemeRelated` method to identify theme-related exceptions.
- Added a new "NuGet" PropertyGroup in `Maui.Android.InAppUpdates.csproj` for package ID, description, and tags. - Replaced hardcoded `Microsoft.Maui.Controls` version with variable `$(MauiVersion)` for improved version management. - Updated ItemGroup for package references while retaining AndroidX library references.
Modified the parameter documentation for the `ShowSnackbar` method. Removed the note about the `clickHandler` parameter being nullable and replaced it with a simpler description of its purpose.
There was a problem hiding this comment.
Pull Request Overview
This PR addresses theme-related crashes in the Android in-app updates library by adding comprehensive error handling and fallback mechanisms to the UI components. The changes focus on resolving the "Error inflating class android.widget.Button" issue mentioned in the title.
- Enhanced error handling in
ShowShortToastwith null checks and exception catching - Refactored
ShowSnackbarwith theme-specific exception handling and toast fallback - Updated Android package dependencies to newer versions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| DefaultUserInterface.cs | Added comprehensive error handling, theme-related exception detection, and fallback mechanisms for toast and snackbar operations |
| Maui.Android.InAppUpdates.csproj | Updated AndroidX and Google Play package versions to newer releases |
| Maui.Android.InAppUpdates.SampleApp.csproj | Updated Microsoft.Maui.Controls and logging package versions |
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
Replaced hardcoded version number for the Microsoft.Maui.Controls package in the project file `Maui.Android.InAppUpdates.SampleApp.csproj` with a variable `$(MauiVersion)` for improved version management.
Contributor
Author
|
@HavenDV github Copilot concerns are probably valid but with the absence of the ability to actually invoke the |
HavenDV
approved these changes
Jul 16, 2025
Collaborator
|
I think we use clickHandler only in one place: in this case, if we have issues with UI, it will restart app - so should be ok for users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*Refactor DefaultUserInterface.cs for Better Error Handling and Code Quality & Prevent Theme-related crashes
The PR essentially says: "I prefer to show a Snackbar, but if your app's theme prevents it, I will gracefully fall back to a Toast and ensure the intended action still takes place, thus maximizing compatibility.