Skip to content

[MaterialAlertDialogBuilder] UnsupportedOperationException when upgrading from 1.10.0 to 1.11.0 #3981

@stkent

Description

@stkent

Description:

Instantiating a MaterialAlertDialogBuilder crashes after updating from library version 1.10.0 to library version 1.11.0. I am able to reproduce this on an emulator running the system image with release name UpsideDownCake, API Level 34, ABI arm64-v8a, Target Android 14.0 (Google Play), revision 12.

This is the crash:

java.lang.UnsupportedOperationException: Failed to resolve attribute at index 4: TypedValue{t=0x2/d=0x7f03013c a=8}, theme={InheritanceMap=[id=0x7f1305b8com.redacted.evergreen.app.develop:style/Redacted.Dialog.ThemeOverlay, id=0x7f1303e4com.redacted.evergreen.app.develop:style/ThemeOverlay.Material3.MaterialAlertDialog, id=0x7f13040dcom.redacted.evergreen.app.develop:style/ThemeOverlay.MaterialComponents.MaterialAlertDialog, id=0x7f130095com.redacted.evergreen.app.develop:style/Base.ThemeOverlay.MaterialComponents.MaterialAlertDialog, id=0x7f1300accom.redacted.evergreen.app.develop:style/Base.V14.ThemeOverlay.MaterialComponents.MaterialAlertDialog, id=0x7f1303b6com.redacted.evergreen.app.develop:style/ThemeOverlay.AppCompat.Dialog.Alert, id=0x7f13008acom.redacted.evergreen.app.develop:style/Base.ThemeOverlay.AppCompat.Dialog.Alert, id=0x7f130089com.redacted.evergreen.app.develop:style/Base.ThemeOverlay.AppCompat.Dialog, id=0x7f1300b6com.redacted.evergreen.app.develop:style/Base.V21.ThemeOverlay.AppCompat.Dialog, id=0x7f1300cbcom.redacted.evergreen.app.develop:style/Base.V7.ThemeOverlay.AppCompat.Dialog, id=0x7f130085com.redacted.evergreen.app.develop:style/Base.ThemeOverlay.AppCompat, id=0x7f130239com.redacted.evergreen.app.develop:style/Platform.ThemeOverlay.AppCompat], Themes=[com.redacted.evergreen.app.develop:style/Redacted.Dialog.ThemeOverlay, forced, com.redacted.evergreen.app.develop:style/Theme.Redacted.Standard, forced, com.redacted.evergreen.app.develop:style/Theme.AppCompat.Empty, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
    at android.content.res.TypedArray.getColor(TypedArray.java:529)
    at com.google.android.material.dialog.MaterialAlertDialogBuilder.<init>(MaterialAlertDialogBuilder.java:131)

Expected behavior:

No crash, as in library version 1.10.0.

Source code:

Invocation: MaterialAlertDialogBuilder(context, 0)

<style name="Redacted.Dialog.ThemeOverlay" parent="ThemeOverlay.Material3.MaterialAlertDialog">
    <item name="buttonBarNegativeButtonStyle">@style/Redacted.Dialog.ButtonStyle.Secondary</item>
    <item name="buttonBarNeutralButtonStyle">@style/Redacted.Dialog.ButtonStyle.Primary</item>
    <item name="buttonBarPositiveButtonStyle">@style/Redacted.Dialog.ButtonStyle.Primary</item>
    <item name="materialAlertDialogBodyTextStyle">@style/Redacted.Dialog.Body.Text</item>
    <item name="materialAlertDialogTitleTextStyle">@style/Redacted.Dialog.Title.Text</item>
    <item name="alertDialogStyle">@style/Redacted.Dialog.Style</item>
    <item name="android:backgroundTint">@color/backgroundPrimaryElevated</item>
    <item name="android:backgroundDimAmount">0.56</item>
</style>

Minimal sample app repro:

I have not attempted to reproduce outside of our primary project at this time.

Android API version: 34.

Material Library version: 1.11.0.

Device: Emulator, see details in description.

To help us triage faster, please check to make sure you are using the latest version of the library.

Possibly related: #3666, though that specifically mentions usage of a beta version of Android U, which I do not believe is the case for this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions