Mysterious stacktrace in Android developer console (bitmap size exceeds 32bits)

后端 未结 3 1476
南旧
南旧 2020-11-30 10:37

I\'m getting the following stacktrace in the developer console. Some report say \"the application won\'t start\" or \"crash at startup\".

I don\'t know what to do, i

相关标签:
3条回答
  • 2020-11-30 11:04

    Bitmap.createBitmap()

    Throws IllegalArgumentException

    if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is <= 0, or height is <= 0

    First make sure your x, y, width and height values are smaller than the source bitmap.

    The issue for me was the matrix. My matrix has a translation value which brought the one of the values outside of the bounds of the input bitmap.

    Hope this helps

    0 讨论(0)
  • 2020-11-30 11:19

    if it 's a matter of quantity, you have to recycle your bitmaps.
    if it's a matter of size (you can't load too big images), you have to load a lighter copy of your bitmap.

    Here is the code to create a smaller image

    Options thumbOpts = new Options();
    thumbOpts.inSampleSize = 4;
    Bitmap bmp = BitmapFactory.decodeFile(imagePath, mThumbOpts);
    

    inSampleSize set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory.
    Use a power of 2 for it to be more efficient.

    This post may be useful

    0 讨论(0)
  • 2020-11-30 11:22

    In my case it was error in this string:

    WebView.getSettings().setUseWideViewPort(true);
    

    Crash was only on API 18 and less

    0 讨论(0)
提交回复
热议问题