Onur Önder
Onur Önder

Reputation: 311

FAILURE: Build failed with an exception. Ionic

I am trying to build a IONIC project but I am facing this exception and I am not able to debug the solution for this.I tried a lot of suggestions but there was no solution.I'm waiting for your help

    1-ionic start test4 tabs
    2-cd test4
    3-ionic platform add android
    4-ionic build android

ERROR

       C:\Users\onurr\test4>ionic build android
       Running command: "C:\Program Files\nodejs\node.exe"  
       C:\Users\onurr\test4\hooks\after_prepare\010_add_platform_class.js       
       C:\Users\onurr\test4   

        add to body class: platform-android

        ANDROID_HOME=C:\Users\onurr\AppData\Local\Android\sdk

        JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_112

        Subproject Path: CordovaLib

       Starting a new Gradle Daemon for this build (subsequent builds will be faster).



     FAILURE: Build failed with an exception.

     * What went wrong:
     Unable to start the daemon process.
     This problem might be caused by incorrect configuration of the daemon.
     For example, an unrecognized jvm option is used.
     Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
     Please read the following process output to find out more:
     -----------------------
     Error occurred during initialization of VM
     Could not reserve enough space for 2097152KB object heap


   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

   Error: cmd: Command failed with exit code 1 Error output:
   FAILURE: Build failed with an exception.

  * What went wrong:
   Unable to start the daemon process.
   This problem might be caused by incorrect configuration of the daemon.
   For example, an unrecognized jvm option is used.
   Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
   Please read the following process output to find out more:
   -----------------------
   Error occurred during initialization of VM
   Could not reserve enough space for 2097152KB object heap


   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Upvotes: 1

Views: 4763

Answers (1)

Prashant G
Prashant G

Reputation: 4900

I'm assuming you're using Windows looking at your stack trace.

Pay attention to this message in your stack trace:

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

This normally happens when you have 32-bit JVM. If your OS is 64-bit, replace 32-bit JVM with 64-bit JVM. It has higher heap constraint and will solve the problem. This is the recommended solution.

Read this oracle documentation for more info.

If your OS is 32-bit, try setting up your OS as following and reissue ionic build android command (might need to restart Command Prompt):

Go to StartControl PanelSystemAdvanced System SettingsAdvanced (tab)Environment VariablesSystem VariablesNew:

Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

Upvotes: 5

Related Questions