【Android】android.content.res.Resources$NotFoundException: Resource “XXX“ is not a Drawable

报错信息

Process: priv.happy.homework_02, PID: 5838
    java.lang.RuntimeException: Unable to start activity ComponentInfo{priv.happy.homework_02/priv.happy.homework_02.MainActivity}: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class EditText
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
		...
		
Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class EditText
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
		...


Caused by: android.content.res.Resources$NotFoundException: Resource "priv.happy.homework_02:drawable/ic_baseline_person_24" (7f070067) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070067 a=-1 r=0x7f070067}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602)
        at android.content.res.Resources.loadDrawable(Resources.java:2540)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
        at android.widget.TextView.<init>(TextView.java:881)
        at android.widget.EditText.<init>(EditText.java:64)
        ...

报错原因

drawable文件夹有很多个,
包括

  • drawable
  • drawable-v24,

drawable-v24里面还可能有drawable和drawable-v24

所以报错一般是因为这几个文件夹里面的内容不一致造成的

具体是因为不同的api在查找资源的时候,直接访问的路径是不一致的,当安卓版本低于7.0时,直接访问drawable,而高于的时候访问drawable-v24

所以需要让所有文件夹里面的文件都一样,因此手动复制一下即可

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

别来BUG求求了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值