#Android tips and workarounds This document covers tips, tricks, and known workarounds for problems with the Cordova Android platform.
Note: If your problem is security related, please read May 26th, 2015 Android Security Issue
##Could Not Create Java Virtual Machine Error When building for Android, you may encounter a set of errors in the Errors List like the following:
Error Could not create the Java Virtual Machine.
Error A fatal exception has occurred. Program will exit.
Error C:\cordova\BlankCordovaApp2\BlankCordovaApp2\platforms\android\cordova\build.bat: Command failed with exit code 1
The problem is that the Ant or Gradle build systems are running out of heap memory when you try to compile your app. To resolve this problem, you can increase the heap of the JVM by setting the following environment variable and restarting Visual Studio:
_JAVA_OPTIONS=-Xmx512M
More specifically, following the instructions from this article:
- Close Visual Studio, if you do not close it - you will need to restart it at the end.
- Open the Control Panel.
- Go to System and Security.
- Go to System.
- Go to Advanced systems settings.
- Go to Environment Variables... (on the Advanced tab).
- Under System Variables, click New
- Variable Name: _JAVA_OPTIONS.
- Variable Value: -Xmx512M.
- Click OK to close the dialog.
- Click OK to close Environment Variables.
- Click OK to close System Properties.
- Now open Visual Studio.
If this does not resolve the issue, you can upgrade to a 64-bit version of the JDK from here and update the JAVA_HOME environment variable to the new install location.