Out of Memoryerror android

不想你离开。 提交于 2019-12-25 18:29:04

问题


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



来源:https://stackoverflow.com/questions/38822583/out-of-memoryerror-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!