Android java.exe finished with non-zero exit value 1

After a lot of surfing, i found out the problem is GC overhead (out of memory). By adding below code to my build.gradle saved my day.

android {

    dexOptions {
        incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK
    }

}

reference - ProcessException: org.gradle.process.internal.ExecException finished with non-zero exit value 2


It must have been a problem with my Java install. I removed all traces of Java (C://program files/Java/jdk) and jre folders and reinstalled it from the official page and now it works fine.


Had the same error encountered which was due to conflicting drawable resources. I did a clean project and the error was no longer encountered.