Out of Memoryerror android

时间:2016-08-08 06:31:51

标签: android memory-leaks

enter image description here

E / art:抛出OutOfMemoryError“无法分配带有16777216个空闲字节的42469452字节分配和31MB直到OOM”

我遇到了这个问题,但是因为它说错误的错误我没有得到。所以任何人都可以帮忙解决这个问题。

请不要拒绝投票问题因为我没有找到问题的原因。

3 个答案:

答案 0 :(得分:1)

缩小图像尺寸使用此链接....

对于PNG

CompressPng

TinyPng

对于JPG

CompressJpeg

TinyJpg

注意: - 如果可能,请将图像尺寸小于50 kb ......

享受编码.........

答案 1 :(得分:0)

当您在logcat中看到消息时,您必须启用MultiDex支持。

To Enable Multidex click here.

如果在启用后仍然存在其他问题,如果仍然面临下面的问题评论,您可能仍会面临问题。

修改您的Gradle文件:

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'
            }
        }
    }
  ...
}

答案 2 :(得分:0)

android:largeHeap="true"放入清单中

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

注意:这可能导致临时解决方案或根本没有解决方案,在这种情况下,请遵循@sushildlh方法来减少图像大小。 这也不是最佳或推荐的过程,但它是一种有效的解决方案click here to know more