Error:Error: Could not create the Java Error: A fatal exception has occurred. Program will exit.

  时间:  2021-06-28 10:52:01


最近使用Android Studio开发Android应用时,引用别人的工程,运行报错。出错信息如下:

Error:Error: Could not create the Java Virtual Machine.
 Error:Error: A fatal exception has occurred. Program will exit.
 Error:Invalid maximum heap size: -Xmx4g
 Error:The specified size exceeds the maximum representable size.
 Error:Execution failed for task ':app:transformClassesWithDexForWandoujiaDebug'.
 > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: 
 java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException


于是各种百度,各种Google,改jvm参数,改studio参数,

org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

改虚拟内存


还是一筹莫展。

后来发现Error:Invalid maximum heap size: -Xmx4g这句话,于是全局搜索4g于是在app/build.gradle中发现这句

dexOptions {
    jumboMode = true    javaMaxHeapSize "4g"}


于是果断把4g改为1g完美运行!!!!



本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。原著地址