Android studio, Invalid maximum heap size

Huỳnh Ngọc Bang picture Huỳnh Ngọc Bang · Jun 29, 2015 · Viewed 7.6k times · Source

After clear project and build succed. I run Android project in Android studio, it appeared error bellow, who can give me solutions resolve problem, thanks!:

> com.android.ide.common.internal.LoggedErrorException: Failed to run command:....
Error Code:
    1
Output:
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    Invalid maximum heap size: -Xmx4g
    The specified size exceeds the maximum representable size.


Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    Invalid maximum heap size: -Xmx4g

My android studio config (studio.exe.vmoptions):

-server
-Xms512m
-Xmx1024m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=150m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Didea.paths.selector=AndroidStudio1.2
-Didea.platform.prefix=AndroidStudio

Answer

Christoph Peltz picture Christoph Peltz · Jul 22, 2015

This is a configuration option in your projects "build.gradle" file. Look for something like this:

dexOptions {
    javaMaxHeapSize "4g"
}