Out of Memoryerror android

2019-09-20 09:01发布

问题:

E/art: Throwing OutOfMemoryError "Failed to allocate a 42469452 byte allocation with 16777216 free bytes and 31MB until OOM"

I got this issue but for what its saying outofmemoryError I'm not getting.So any one can help out to solve this issue.

Please do not down vote question As I am not getting for what the issue is been created.

回答1:

Reduce image size use this links....

For PNG

CompressPng

TinyPng

For JPG

CompressJpeg

TinyJpg

Note:-make image size less than 50 kb if possible ......

enjoy coding.........



回答2:

You have to enable you MultiDex Support as you see the message in logcat.

To Enable Multidex click here.

you might still face issue if some other issue also exist after enabling it try if still face problem comment below.

Modify your Gradle file:

android {
    ....

    dexOptions {
        preDexLibraries = false
        incremental true
        javaMaxHeapSize "4g"
    }
    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = ['--multi-dex']
            } else {
                dx.additionalParameters += '--multi-dex'
            }
        }
    }
  ...
}


回答3:

put android:largeHeap="true" in manifest like this

<application android:name="android.support.multidex.MultiDexApplication" android:icon="@drawable/appicon" android:label="@string/app_name" android:largeHeap="true" android:theme="@style/AppTheme">

NOTE: This might result in temporary solution or no solution at all, in that case please follow @sushildlh methods to reduce image sizes. Also this is neither the best nor the recommended process of doing it but it is an effective solution. click here to know more