Error:Android Gradle Build Target: java.lang.OutOfMemoryError: Java heap space

337 views
Skip to first unread message

Hugh Smith

unread,
Aug 25, 2015, 4:40:42 PM8/25/15
to adt-dev
I'm using Android Studio 1.4

I've followed the documentation to add a separate studio.vmoptions  setting --Xmx4096m
I can't get it to work.

I've tried restarting Android Studio.
That didn't work.

I've put the studio.vmoptions in the ~/Library/Preferences/Android Studio<pick your version>  folder  (everything from Preview 1.3 to 1.4)
again with a AS restart.
That didn't work.

I've created an created an environment variable  export STUDIO_VM_OPTIONS=/Users/hsmith/mySpecialPath/studio.vmoptions
again with a restart
That didn't work.

I even tried adding this to my build.gradle
dexOptions {
    javaMaxHeapSize "4g"
}
still no luck.
The build seems to be successful.  It's when I ask it to run a native debug session that I get this error.  
I can run gradle assembledebug from the terminal command and get a successful build.  

We're struggling with trying to migrate our tool chain for our large, mostly native c/c++ android application from a command line ndk-build / ant debug / ndk-gdb command line debugging, based strategy
to Android Studio. I'm not sure the tool is ready for us but we really want to continue the pilgrimage to get it working.  I've got lot's of questions but this is the current road block.
any help is appreciated.
Thanks 
Hugh


Greg Macdonald

unread,
Aug 26, 2015, 5:47:45 PM8/26/15
to adt-dev
I am seeing the same problem in AS 1.3 after changing buildToolsVersion from 22.0.1 to 23.0.0

UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.lang.ref.Finalizer.register(Finalizer.java:87)
    at java.lang.Object.<init>(Object.java:37)
    at java.io.InputStream.<init>(InputStream.java:45)
    at java.util.zip.ZipFile$ZipFileInputStream.<init>(ZipFile.java:659)
    at java.util.zip.ZipFile.getInputStream(ZipFile.java:356)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:270)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:672)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
    at com.android.dx.command.dexer.Main.run(Main.java:275)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dex<Flavor>Debug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3

Greg Macdonald

unread,
Aug 27, 2015, 11:35:42 AM8/27/15
to adt-dev
I have also not been able to find a solution by configuring memory. Our project is not really large, but the two things about our project that may be contributing to this is we are using NDK and MultiDex.  Perhaps one of them is a factor.
Reply all
Reply to author
Forward
0 new messages