2

[I am getting error while building the android apk in ionic. It says "Could not reserve enough space for 2097152KB object heap. I tried various option but didnt work out. Please Help"][1]

<img src="https://i.stack.imgur.com/O7Oka.jpg">
trincot
  • 317,000
  • 35
  • 244
  • 286
Pravin
  • 21
  • 3
  • Possible duplicate of [Getting Gradle error "Could not reserve enough space for object heap" constantly in Intellij IDEA](http://stackoverflow.com/questions/26143740/getting-gradle-error-could-not-reserve-enough-space-for-object-heap-constantly) – AKX Nov 22 '16 at 11:44

2 Answers2

3

I was facing the same problem. For me the solution provided by Roman Ashikhmin worked but I found that you also need following Environment Variable too,

GRADLE_OPTS : -Xmx2048M

along with the

_JAVA_OPTIONS : -Xmx1024M

Note: For _JAVA_OPTIONS I tried going over 1024M to 2048M or even 4096M but those options don't work. You can do 512M & or 1024M. For GRADLE_OPTS gogin over 2048M didn't work either.

I'm on:

Java 32bit jdk-8u141

global packages:

@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 2.3.0

System:

Node       : v6.11.0
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 3.10.10
Ahmad
  • 2,629
  • 3
  • 22
  • 27
1

Try to add a Windows Environment Variable named _JAVA_OPTIONS with value -Xmx512M.

It helped me to resolve the same issue.

kiecodes
  • 1,642
  • 14
  • 28