Search code examples
androidgradleandroid-multidex

transformClassesWithDexForDebug fails with non-zero exit value 3


I'm compiling multidex project and gradle gives me this:

Execution failed for task ':Project:transformClassesWithDexForLiteDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3

I suppose it happens because gradle runs out of memory and there are solutions to add:

dexOptions {
    javaMaxHeapSize "4g"
}

But in my case I get another error from gradle: Cannot resolve symbol 'javaMaxHeapSize'.

And it just does not compile. Any help very appresciated!


Solution

  • To me, if you have this kind of error, it is because you misplaced this dexOptions:

    What you have to do is to put it as a child of android in your module (I guess called app) gradle file.

    Like this:

    android {
        signingConfigs {
    
        }
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
        defaultConfig {
    
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.Lolo
    
            }
            debug{
    
            }
        }
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }