material-components / material-components/material-components-android
[Snackbar] UnsupportedOperationException: Failed to resolve attribute at index 0
Open
Nobody has claimed this yet.
bug
Widget: Snackbar
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Description: In some apps using M2 styles, creating a Snackbar triggers the following warning:
Failed to inflate ColorStateList, leaving it to the framework
java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f040135 a=-1}, theme={
InheritanceMap=[id=0x7f12036a...:style/ThemeOverlay.Material3.Button.TextButton], Themes=[...]}
at android.content.res.TypedArray.getColor(TypedArray.java:536)
at androidx.core.content.res.ColorStateListInflaterCompat.inflate(ColorStateListInflaterCompat.java:157)
at androidx.core.content.res.ColorStateListInflaterCompat.createFromXmlInner(ColorStateListInflaterCompat.java:122)
at androidx.core.content.res.ColorStateListInflaterCompat.createFromXml(ColorStateListInflaterCompat.java:102)
at androidx.core.content.res.ResourcesCompat.inflateColorStateList(ResourcesCompat.java:259)
at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:234)
at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:516)
at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:46)
at androidx.appcompat.widget.TintTypedArray.getColorStateList(TintTypedArray.java:178)
at androidx.appcompat.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:66)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:86)
at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:292)
at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:288)
at com.google.android.material.theme.MaterialComponentsViewInflater.createButton(MaterialComponentsViewInflater.java:43)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:156)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1654)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1705)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:950)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:886)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:850)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1012)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:973)
at android.view.LayoutInflater.inflate(LayoutInflater.java:571)
at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
at com.google.android.material.snackbar.Snackbar.makeInternal(Snackbar.java:250)
at com.google.android.material.snackbar.Snackbar.make(Snackbar.java:177)
at com.google.android.material.snackbar.Snackbar.make(Snackbar.java:198)
...
Material Library version: 1.14.0-alpha10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing Snackbar.make with Material Library 1.14.0-alpha10 in an app using M2 styles, then follow the stack from Snackbar.makeInternal through MaterialButton and AppCompatBackgroundHelper. Done means creating the Snackbar no longer produces the Failed to resolve attribute warning or UnsupportedOperationException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100