Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Failed to inflate ColorStateList - error fix for CheckBox #24658

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Sep 8, 2024

Description

In the styles.xml file, I noticed that Widget.Material3.CompoundButton.CheckBox is set as the parent for MauiCheckBox. However, Maui.MainTheme has Theme.MaterialComponents.DayNight as its parent.

After changing the parent of Maui.MainTheme to Theme.Material3.DayNight.NoActionBar, the error disappeared, but I had some reservations about whether that was the right solution.

So I dug deeper and found in src/Core/AndroidNative/maui/build/intermediates/incremental/release/mergeReleaseResources/merger.xml the following code

<style name="Base.Widget.Material3.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox">
    
    <item name="android:textAppearance">?attr/textAppearanceBodyMedium</item>
    <item name="errorAccessibilityLabel">@string/error_a11y_label</item>
    <item name="buttonTint">@color/m3_checkbox_button_tint</item>
    <item name="buttonIconTint">@color/m3_checkbox_button_icon_tint</item>
    <item name="buttonIcon">@null</item>
</style>

Issues Fixed

Fixes #18897
Fixes #24602

Before After

@kubaflo kubaflo requested a review from a team as a code owner September 8, 2024 16:19
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 8, 2024
@@ -65,6 +65,8 @@
<!-- remove all the min sizes as MAUI manages it -->
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">0dp</item>
<!-- remove the button tint as MAUI manages it -->
<item name="buttonTint">?attr/colorPrimary</item>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also be set to @null

Copy link
Member

@mattleibow mattleibow Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think colorPrimary is defined in the templates only? What will happen if you were to remove it?

Maybe @null or anything else may be better? Of does this color always exist in a plain android app with no styles or colors?

I see it at the top of the file...

@PureWeen
Copy link
Member

PureWeen commented Sep 8, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PureWeen PureWeen merged commit 277ce9f into dotnet:main Sep 9, 2024
97 checks passed
@AlleSchonWeg
Copy link

Hi,
i updated nightly to version 8.0.90-ci.net8.24459.1 and the problem persists. Do I need manual changes in existing projects?

@MartyIX
Copy link
Contributor

MartyIX commented Sep 10, 2024

Looking at timestamps, it looks to me that 8.0.90-ci.net8.24459.1 was compiled before this fix was merged.

@AlleSchonWeg
Copy link

Ah okay. I will try again tomorrow.

@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Oct 1, 2024
@samhouts samhouts added fixed-in-9.0.0-rc.2.24503.2 and removed fixed-in-net9.0-nightly This may be available in a nightly release! labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants