java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable

java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable
或者 java.lang.NoSuchMethodError:android.content.Context.getDrawable

原因:Resources的getDrawable方法和Context类的getDrawable方法都是API21才添加的,低版本系统无法找到该方法所以报异常。


  解决办法:
     使用Resources的 getDrawable(res),但是该方法在API22已废弃。
     使用 ContextCompat.getDrawable(context,res)。

猜你喜欢

转载自blog.csdn.net/qq_29518175/article/details/79815307