2
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1

Continously getting this error everytime i try to run the project

Already added

dexOptions {
    javaMaxHeapSize "4g"
}

Also, have added multidexEnabled true

in build.gradle and restarted android studio many a times, but still receiving the same error.

Not even able to run the app once.

-------------SOLVED-------------

Previously i had put environment variable in the system named _JAVA_OPTIONS with -Xmx1024M value and i changed it to -Xmx2048M and it solved the issue.

fadden
  • 51,356
  • 5
  • 116
  • 166
Mit
  • 318
  • 2
  • 10
  • I had the same problem, and never realised that uncommenting this line in the gradle.properties file fixes it: `org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8` – Adrian Wreyford Apr 15 '16 at 18:50

2 Answers2

2

If you already setup your gradle to accept MultiDex options, just set the max heap size for DexOptions:

dexOptions { 
    javaMaxHeapSize "4g"
}
Chris Stillwell
  • 10,266
  • 10
  • 67
  • 77
1

Add multiDexEnabled true in defaultConfig in build.gradle file

defaultConfig {
        multiDexEnabled true
    }
sree
  • 773
  • 2
  • 12
  • 25
  • post your build.gradle file – sree Feb 11 '16 at 11:48
  • have already added multiDexEnabled true...still getting the same error again and again – Mit Feb 11 '16 at 12:37
  • post your build.gradle file – sree Feb 11 '16 at 12:57
  • Hi, sree, already implemented MultiDex the same way, only thing i didnt do was put incremental true inside dexOptions which i did and still not working, getting the same error – Mit Feb 12 '16 at 04:39
  • Solved the problem, please check the edited version of my post above for the same. Thanx anyways for your help @sree upvoted your answer for taking your precious time out and answering the query – Mit Feb 12 '16 at 06:31