RemoteViews使用setImageResource出错
错误提示:
android.widget.RemoteViews$ActionException:
view: android.support.v7.widget.AppCompatImageView can’t use method with RemoteViews: setImageResource(int)
解决方法:
setting the appcompat version to ‘com.android.support:appcompat-v7:23.0.1’ or lower makes the error go away.
原因:
Issue:
android.support.v7.widget.AppCompatImageView introduced in version 23.1.0 of appcompat-v7 support library is missing the annotation:
@android.view.RemotableViewMethod for the following
methods:setImageResource(int)、setBackgroundResource(int)
Hence breaking RemoveViews#apply(Context, ViewGroup) when the remote view contains an ImageView and either of the above mentioned methods are called.
Details:
ImageView#setImageResource(int) and View#setBackgroundResource(int) are both annotated with @RemotableViewMethod annotation so it works with the RemoveViews API.
However since the @RemotableViewMethod annotation is not itself annotated as @Inherited, subclasses of ImageView and View classes when they override the 2 methods mentioned earlier (what AppCompatImageView did), the check for the RemotableViewMethod annotation in RemoveViews#getMethod(View, String, Class) fails for annotation not present.
更多相关文章
- OpenCV 连接 Android(安卓)IP摄像头
- Android开发错误信息收集
- 【android】Error: Static interface methods are only supporte
- Android(安卓)Sqlite Failed to open database(无法打开数据库文
- Android(安卓)studio b Error: No resource found that matches
- Android(安卓)Studio编译报错:sdk:minSdkVersion 1 cannot be sma
- Android中binderDied()以及"Unknown binder error code" 出现的
- android studio 3.0 报错 Unable to find method 'com.android.b
- android View.GONE 失效原因