material-components-android
material-components-android copied to clipboard
[ShapeableImageView] Crash occasionally
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.
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: <com.google.android.material.imageview.ShapeableImageView android:id="@+id/big_setting_account_avator" android:layout_width="@dimen/big_setting_user_avatar" android:layout_height="@dimen/big_setting_user_avatar" android:layout_alignParentEnd="true" android:layout_marginTop="@dimen/big_setting_user_avatar_margin_top" android:layout_marginEnd="@dimen/big_setting_account_avator_margin_end" android:visibility="invisible" app:shapeAppearance="@style/PortraitCircle" /> 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 of the library.
We also happily accept pull requests.
Hi @chenqingru , could you try on the latest version of the library (1.8.0)?
ok,thanks for you reply
Is the issue still happening with the latest library version?
The same exception occurs with MaterialDivider on initialization. Library version 1.9.0
This issue for ShapeableImageView is still there in the version: 1.12.0-beta01
should set strokeColor
app:strokeColor="@null"