【bug】使用glide报错:Cannot pool recycled bitmap

Glide是日常加载图片的第三方库,通常按照标准的接口使用是不会出现问题的。这个错误是我在分享网页的时候,需要生成缩略图,就用glide下载下来,裁剪成微信需要的大小,然后再把图片回收。看似没有问题,却报错了。

错误信息

Caused by: java.lang.IllegalStateException: Cannot pool recycled bitmap
at com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.put(LruBitmapPool.java:108)
at com.bumptech.glide.load.resource.bitmap.BitmapResource.recycle(BitmapResource.java:57)
at com.bumptech.glide.load.engine.LockedResource.recycle(LockedResource.java:90)
at com.bumptech.glide.load.engine.LockedResource.recycle(LockedResource.java:90)
at com.bumptech.glide.load.engine.EngineResource.recycle(EngineResource.java:75)
at com.bumptech.glide.load.engine.ResourceRecycler.recycle(ResourceRecycler.java:22)
at com.bumptech.glide.load.engine.Engine.onResourceReleased(Engine.java:398)
at com.bumptech.glide.load.engine.EngineResource.release(EngineResource.java:116)
at com.bumptech.glide.load.engine.Engine.release(Engine.java:362)
at com.bumptech.glide.request.SingleRequest.clear(SingleRequest.java:326)
at com.bumptech.glide.manager.RequestTracker.clearAndRemove(RequestTracker.java:72)
at com.bumptech.glide.RequestManager.untrack(RequestManager.java:663)
at com.bumptech.glide.RequestManager.untrackOrDelegate(RequestManager.java:631)
at com.bumptech.glide.RequestManager.clear(RequestManager.java:627)
at com.bumptech.glide.RequestManager.onDestroy(RequestManager.java:374)
at com.bumptech.glide.manager.ActivityFragmentLifecycle.onDestroy(ActivityFragmentLifecycle.java:65)
at com.bumptech.glide.manager.SupportRequestManagerFragment.onDestroy(SupportRequestManagerFragment.java:215)

解决方案

就一句话,不要手动的回收下载下来的图片。因为glide有一套图片回收逻辑,如果你手动回收了bitmap,glide在回收的时候就找不到了,就会报这个错。

你可能感兴趣的:(【bug】使用glide报错:Cannot pool recycled bitmap)