Search code examples
androidout-of-memoryjack-compiler

Out of memory with jack


I'm testing the new compilation chain to start using lambdas.

My build.gradle file contains:

android {
    ...
    compileSdkVersion 23
    buildToolsVersion "24 rc3"

    dexOptions {
        jumboMode true
    }

    defaultConfig {
        applicationId "my.app.id"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true

        jackOptions {
            enabled true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

I'm using Android Studio 2.1.1.

When I build the app the compilation takes ages and then ends with an Out of memory error:

Execution failed for task ':app:compileAppNameJavaWithJack'.

java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded

Sometimes the compilation just hangs when performing:

:app:compileMyAppNameDebugJavaWithJack

I found in the troubleshooting section here a way to fix it but I can't find the .jack file with the configuration. In this bug report someone mentioned that the file could have been renamed to jack.settings but I can't find that file either.

Do you know where the file is? Do you know how to fix the Out of memory error?


Solution

  • I managed to fix the issue setting:

    org.gradle.jvmargs=-Xmx2048M
    

    in the gradle.propertiesfile

    Check here for more info about the setting