0

I am trying to deploy my freshly created Ionic 3 app (I am using 64-bit Windows 10) on my mobile but it is throwing error after running ionic cordova run android --device:

> cordova build android
ANDROID_HOME=D:\android-sdk\tools\bin
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_161
Subproject Path: CordovaLib
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Error: cmd: Command failed with exit code 1

[ERROR] An error occurred while running cordova build android (exit code 1).

I have installed Android studio. I have added a system variable _ JAVA_OPTIONS with value -Xmx512M I have also added a system variable GRADLE_OPTS with value -Xmx2048M

Otherwise I have:

ANDROID_HOME=D:\android-sdk\tools\bin
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_161 

Why is this error still occurring?

Phonolog
  • 6,321
  • 3
  • 36
  • 64
Thinker
  • 5,326
  • 13
  • 61
  • 137

1 Answers1

0

Here is how to fix it on a Windows platform:

Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables -> New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

Don't ignore the score and underscore characters.

Gauravbhai Daxini
  • 2,032
  • 2
  • 22
  • 28