错误提示:
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.