这两天把gradle升级到了gradle-3.4.1
com.android.tools.build:gradle升级到了com.android.tools.build:gradle:2.3.0
结果老是编译不通过,报
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list D:\Project\Police\JingWuTong\Src\build\intermediates\multi-dex\gsjwtIII\debug\maindexlist.txt --output D:\Project\Police\JingWuTong\Src\build\intermediates\transforms\dex\gsjwtIII\debug\folders\1000\1f\main D:\Project\Police\JingWuTong\Src\build\intermediates\transforms\jarMerging\gsjwtIII\debug\jars\1\1f\combined.jar}
看意思是编译时内存不够
经过搜索,在gradle文件中增加
dexOptions {
incremental true //增量编译,能够加快编译应用速度
javaMaxHeapSize "4g" //在Gradle 进行dex的可能会遇到内存不够用的情况,错误信息大概是java.lang.OutOfMemoryError: GC overhead limit exceeded。这个时候只需要配置dexOptions的javaMaxHeapSize大小即可
}
即可解决,顺利升级gradle到3.x