Android Glide clear()方法可以';无法解决

Android Glide clear()方法可以';无法解决,android,android-glide,Android,Android Glide,我正在尝试修复Android应用程序中的OutOfMemoryException,在我的recyclerView中,我想写: @Override public void onViewRecycled(final ViewHolder viewHolder) { Glide.clear(viewHolder.getImageView()); } 但我得到了一个错误: 错误:找不到清除符号方法(ImageView) 我正在使用: implementation 'com.github.bum

我正在尝试修复Android应用程序中的
OutOfMemoryException
,在我的recyclerView中,我想写:

@Override
public void onViewRecycled(final ViewHolder viewHolder) {
    Glide.clear(viewHolder.getImageView());
}
但我得到了一个错误:

错误:找不到清除符号方法(ImageView)

我正在使用:

implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
根据for
clear
方法

/**
   * Cancel any pending loads Glide may have for the view and free any resources that may have been
   * loaded for the view.
   *
   * <p> Note that this will only work if {@link View#setTag(Object)} is not called on this view
   * outside of Glide. </p>
   *
   * @param view The view to cancel loads and free resources for.
   * @throws IllegalArgumentException if an object other than Glide's metadata is put as the view's
   *                                  tag.
   * @see #clear(Target)
   */
  public void clear(@NonNull View view) {
    clear(new ClearTarget(view));
  }

使用
Glide.with(viewholder.itemView.getContext()).clear(viewholder.getImageView())-这可能无法解决OOM的问题,但这是清除图像的正确语法。@您应该将注释作为答案提交,以便OP可以将其标记为正确答案
Glide.with(viewHolder.getImageView().getContext()).clear(viewHolder.getImageView());