1

Anyone know how to get by the "Out of Memory" error on Android Studio when an image you have is like 102941092301mb too big and it crashes your app when you debug?
pls I need help, this image looks terrible when it isn't the resolution I would like...

Comments
  • 0
    This is a duplicate of "Why a I getting out of memory error exception on Android?"
  • 1
    all seriousness asiade, use BitmapFactory.decodeStream() or use a BitmapFactory.Options and set BitmapFactory.Options.inSampleSize = 4;
  • 0
    @calmyourtities
    hahahaha
    you must think I'm some fucking genius to even begin thinking where to put that code...
    I'm a ninth grader bro, I'm like on my way trying to teach myself, I appreciate the help, but is there anyway you can explain why, and then also tell me where to put this, even though I suspect it's the class file in android studio but I don't feel like effing up this project so soon. thanks man.
  • 1
    I mean if the image is so big that it crashes Android Studio then it's probably so big that it'll crash any Android device, so you might want to consider scaling it down in Photoshop/Gimp/paint.NET/etc
  • 0
    @coolguy101 I'm in ninth grade too, and it's because of the buffer size. the buffer is memory where the image is stored, so, for example, if the image is 120 bytes, but the buffer is 100 bytes, then the buffer couldn't store the image, just like how you can't store a 10 gb file on an 8gb flash drive. so, you have to manually increase the buffer size to compensate for the size of the image. I'm kinda busy right now, but later I can show you some samples from my apps.
  • 0
    what @Ezard is trying to say, is that you can't make a buffer big enough for the size of the image you said
  • 0
    Exactly what @calmyourtities said.
    With a loop to see what sample size is needed.
    If you don't know where to put it, go to Android developer site it's full of examples.
Add Comment