Android XML: RuntimeException: Failed to resolve attribute at index 6

后端 未结 10 1916
梦如初夏
梦如初夏 2020-12-01 23:44

Hello dear stackoverflower,

In my project, i am using the new \"android design library\". The problem is, that there is a runtime exception which says(Im trying to c

10条回答
  •  猫巷女王i
    2020-12-01 23:49

    For my case, this issue started showing up after migrating to AndroidX. The scenario was I implemented custom views that extends AppCompatEditText and set custom styles as well. I ran into this issue while running the unit tests.

    The error logs show this as the root cause:

    Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0300f9 a=2}
        at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:946)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
    

    In the styles I was using Base.Widget.AppCompat.EditText:

    
    

    Changing the parent to Android's base android:Widget.EditText removed the error and didn't change any behavior/UI for me.

    It's strange since digging through the inheritance structure of Base.Widget.AppCompat.EditText, the root parent is also android:Widget.EditText.

提交回复
热议问题