要在进程中运行dex,Gradle守护程序需要更大的堆。它目前有大约3641 MB

时间:2016-06-02 07:25:17

标签: android android-studio

在5.0以上的设备中工作正常。除了 multidex 支持之外,还有解决此问题的方法吗?

明细

To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 3641 MB.

For faster builds, increase the maximum heap size for the Gradle daemon to more than 4096 MB.
To do this set org.gradle.jvmargs=-Xmx4096M in the project gradle.properties.

For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> 
    com.android.build.api.transform.TransformException: 
    com.android.ide.common.process.ProcessException: 
    java.util.concurrent.ExecutionException: 
    com.android.ide.common.process.ProcessException:  
    org.gradle.process.internal.ExecException:
    Process 'command '/usr/local/jdk1.7.0_71/bin/java'' finished with non-zero exit value 2

我尝试了以下解决方案。错误仍然没有消失。

gradle

buildTypes {

    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    }
}
dexOptions {
    preDexLibraries true
    javaMaxHeapSize "3g"
    incremental true
    dexInProcess = true
}

gradle属性

     org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m

1 个答案:

答案 0 :(得分:0)

有一位关于64k限制的优秀官员article。你基本上有很多选择:

  • 检查依赖项并删除那些不需要的或可以用较小的
  • 替换的依赖项
  • 配置ProGuard以删除未使用的代码
  • 在您的应用中实施MultiDex

关于" Gradle守护进程需要更大的堆",这不是问题,而是优化提示。