查看详细连接RuntimeException: Canvas: trying draw too large bitmap
1.线上遇到crash:
2.发生位置: 原因是Glide.....into(new CustomTarget),Bitmap计算超过100m就会报此Exception
public static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB
@Override
protected void throwIfCannotDraw(Bitmap bitmap) {
super.throwIfCannotDraw(bitmap);
int bitmapSize = bitmap.getByteCount();
if (bitmapSize > MAX_BITMAP_SIZE) {
throw new RuntimeException(
"Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
}
}
3.修改如下: 判断如果超过100m,则去掉硬件加速
imageview.setLayerType(View.LAYER_TYPE_SOFTWARE, null)