-7

Actually, I am trying to create a app with multimedia files which includes images . While I am loading the app in any devices facing the problem, the apps get crash in the middle of the process with the error "

java.lang.OutOfMemoryError: Failed to allocate a 12559948 byte allocation with 2232360 free bytes and 2MB until OOM"

.

I also declare in my manifest these code:

<application
    android:name=".AppHelper.AppController"
    android:allowBackup="true"
    android:icon="@drawable/ring_logo"
    android:label="@string/app_name"
    android:hardwareAccelerated="false"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
Zaid Mirza
  • 3,540
  • 2
  • 24
  • 40

1 Answers1

0

Its usually due placing high resolution images in wrong drawable folder. For Example, you have an image whose resolution and density is high (Suppose 640dpi) and you place it inside drawble folder instead of drawable-xxxhdpi folder. When app will run on high resolution device, System will try to scale up that image according to resolution of the device. Resulting image will take more memory and OutOfMemory exception will be thrown after sometime of using app. So you should create images for every possible density (dpi,hdpi,xdpi,xxdpi,xxxdpi) or put your high resolution image inside drawable-xxxhdpi. System will scale down automatically for lower densities.

Zaid Mirza
  • 3,540
  • 2
  • 24
  • 40