Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap(

Posted nelsonlei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap(相关的知识,希望对你有一定的参考价值。

ionic build Android后的报错问题

 

   ionic 升级了splashscreen和statusbar的插件后,执行ionic build android会一直报打包错误。原因是过低的Android-platform版本不支持新的 splashscreen和statusbar插件

  解决 办法是:  ionic platform add [email protected]      添加Android平台前加上版本号就行

  然而,又有了新的问题:Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap

 

  技术分享图片

 

  1、这时候报虚拟内存不足-----------因为我的电脑是32位的Win7 ,经测试,64位的没有这个错误。一般报这个内存不足,java的做法就是去eclipse的option修改jre的参数值就行了。

  2、但ionic的做法有点不一样:在 ionic platform add [email protected]  后,在 platformsandroidcordovalibuilders 的文件夹下会有一个文件 GradleBuilder.js 

  3、用记事本打开这个文件,在内容中找到 args.push(‘-Dorg.gradle.jvmargs=-Xmx2048m‘);把这个2048m调小,具体看你的机器,我调的为256m

  4、如果没有找到 args.push(‘-Dorg.gradle.jvmargs=-Xmx258m‘);  那么在 GradleBuilder.prototype.getArgs 的函数里面的return前加上这句代码就行。

  5、最后执行ionic build android就可以跟之前一样的打包了

 

以上是关于Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap(的主要内容,如果未能解决你的问题,请参考以下文章

!MESSAGE Error occurred during status handling

解决ubuntu下error occurred during the signature verification

an error occurred during the file system check错误的解决

TestNG运作报错An interanl error occurred during:"Launching first"

用Eclipse运行Java文件报错Error occurred during initialization of boot layer

Error occurred during initialization of VM java/lang/NoClassDefFoundError