Fix Note: OutOfMemory of Android Crop Library

Error Log screenshot

Open source Library: https://github.com/jdamcd/android-crop
Platform: Android

Today I finally fixed the OutOfMemory problem of the image crop library that I used to crop the profile picture given from the user;

The problem happened when a high-resolution image is being inputted, e.g over 1M to crop; Android hits an OutOfMemory problem when decoding the image;

It is easy to solve the above problem, simply set the SIZE_LIMIT value in CropImageActivity.java
  • The origin value is 4096, it may crash if the device isn’t having enough memory like my phone;
  • The safe value is 1024, which I am using it to fix the problem;

Source location: https://github.com/jdamcd/android-crop/blob/master/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java

Change From:

</div>
<div>private static final int SIZE_LIMIT = 4096;</div>
<div>
To:

</div>
<div>private static final int SIZE_LIMIT = 1024;</div>
<div>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s