material-components / material-components/material-components-android

[ShapeableImageView] Crash occasionally

Aperta
#3,296 6 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Feature: Shape Need more info
Lingua principale
Java
Stelle
17.4k
Fork
3.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**Description:** Hi, I found a crash on ShapeableImageView. The version used is 1.5.0. Error log :
ResourcesCompat: Failed to inflate ColorStateList, leaving it to the framework
ResourcesCompat: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0400f3 a=-1}
ResourcesCompat: at android.content.res.TypedArray.getColor(TypedArray.java:477)
ResourcesCompat: at androidx.core.content.res.ColorStateListInflaterCompat.inflate(ColorStateListInflaterCompat.java:13)
ResourcesCompat: at androidx.core.content.res.ColorStateListInflaterCompat.createFromXmlInner(ColorStateListInflaterCompat.java:13)
ResourcesCompat: at androidx.core.content.res.ColorStateListInflaterCompat.createFromXml(ColorStateListInflaterCompat.java:18)
ResourcesCompat: at androidx.core.content.res.ResourcesCompat.inflateColorStateList(ResourcesCompat.java:13)
ResourcesCompat: at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:13)
ResourcesCompat: at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:9)
ResourcesCompat: at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:1)
ResourcesCompat: at com.google.android.material.resources.MaterialResources.getColorStateList(MaterialResources.java:3)
ResourcesCompat: at com.google.android.material.imageview.ShapeableImageView.(ShapeableImageView.java:18)
ResourcesCompat: at com.google.android.material.imageview.ShapeableImageView.(ShapeableImageView.java:2)
ResourcesCompat: at java.lang.reflect.Constructor.newInstance0(Native Method)
ResourcesCompat: at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
ResourcesCompat: at android.view.LayoutInflater.createView(LayoutInflater.java:647)
ResourcesCompat: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:807)
ResourcesCompat: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
ResourcesCompat: at android.view.LayoutInflater.rInflate(LayoutInflater.java:880)
ResourcesCompat: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:841)
ResourcesCompat: at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
ResourcesCompat: at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

**Expected behavior:** ShapeableImageView doesn't crash

**Source code:**
the crash on source code is: TypedArray

if (type == TypedValue.TYPE_ATTRIBUTE) {
final TypedValue value = mValue;
getValueAt(index, value);
throw new UnsupportedOperationException(
"Failed to resolve attribute at index " + attrIndex + ": " + value
+ ", theme=" + mTheme);
}

**Minimal sample app repro:** use it in layout.xml for example:

**Android API version:** 33

**Material Library version:** 1.5.0

**Device:** Device on which the bug was encountered here

To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.

We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione minima di layout.xml usando ShapeableImageView e il valore app:shapeAppearance segnalato su Android API 33. Leggi lo stack trace dal costruttore di ShapeableImageView fino alla risoluzione dei colori di TypedArray; il lavoro è completato quando l'esempio viene inflato senza il crash segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, java
Ambito
mobile
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.