Search code examples
androidgradleheap-memorydex

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


I'm getting this message when I build my APP in Android Studio:

Running dex as a separate process.

To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html

I don't know exactly what it means as I'm new in this, and how to fix it. I have a build.gradle (project), a settings.gradle and build.gradle (APP). Which one do I have to modify and how?

Thank you!


Solution

  • Set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. For more information see https://docs.gradle.org/current/userguide/build_environment.html

    You can also add this line in your build.gradle

    android {
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }