11

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, it doesn't mention any on my app's class! Anyone got the same error and found a fix?

java.lang.IllegalArgumentException: bitmap size exceeds 32bits
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:695)
at android.view.View.buildDrawingCache(View.java:6646)
at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1345)
at android.view.ViewGroup.drawChild(ViewGroup.java:1591)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6996)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6996)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2054)
at android.view.ViewRoot.draw(ViewRoot.java:1632)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1335)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1991)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4358)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
erwan
  • 1,285
  • 5
  • 14
  • 28
  • 1
    It may be the case your main Activity loads resources related to its layout "outside" of your scope. Anyway, it seems so that there's some image causing problems and if there aren't too many of them try replacing them one by one with e.g. default android icon until you find the one causing problems. – harism Feb 21 '12 at 00:31
  • I was facing the same problem sometimes when I was developing a widget. It usually was cured by (it was in Eclipse btw) cleaning the project (menu Project->Clean) then refreshing the project and building it again. But if somebody knows the exact reason why it happens, that would be awesome and I definitely gonna vote up for the answer! ;) – avepr Feb 21 '12 at 01:04

3 Answers3

4

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

Community
  • 1
  • 1
Cyril Leroux
  • 2,599
  • 1
  • 26
  • 25
  • 2
    This wont work, it has nothing to do with the size, see my question: [here](http://stackoverflow.com/questions/15008386/android-bitmap-size-exceeds-32-bit-in-dialogfragment/15008630#15008630) – stefple Feb 22 '13 at 07:58
  • 1
    How does this solve the problem? There's no `ImageView` mentioned in the question nor any sign of creating a bitmap! `View.buildDrawingCache` is creating an image too large for some reason.... – TWiStErRob Aug 17 '14 at 19:30
1

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

Community
  • 1
  • 1
vvbYWf0ugJOGNA3ACVxp
  • 1,086
  • 10
  • 23
0

In my case it was error in this string:

WebView.getSettings().setUseWideViewPort(true);

Crash was only on API 18 and less

Igor Kostenko
  • 2,754
  • 7
  • 30
  • 57