1
votes

I build an app on Ionic framework, it works on the browser but when I try to compile it on the emulator I have got this error:

Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED) Starting a Gradle Daemon (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 Manual chapter on the daemon at https://docs.gradle.org/5.3.1/userguide/gradle_daemon.html Process command line: C:\Program Files (x86)\Java\jdk1.8.0_201\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=SA -Duser.language=ar -Duser.variant -cp C:\Gradle\gradle-5.3.1\lib\gradle-launcher-5.3.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.3.1

    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. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org C:\Gradle\gradle-5.3.1\bin\gradle: Command failed with exit code 1 [ERROR] An error occurred while running subprocess cordova.

    cordova run android exited with exit code 1.
    
    Re-running this command with the --verbose flag may provide more information.
    
2

2 Answers

2
votes

This is because the path to Android Sdk is not set correctly. Please check the correct path for Sdk, tools, platform-tools, emulator and Android build-tools.

Please, realize that the configuration recommended for Ionic has changed a bit. Now the notation recommended is as follows:

ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)

In Linux or Mac OS X configure the path into the ~/.bashrc, ~/.bash_profile file:

export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools

At the end, after save the configuration dont forget to do the command:

source ~/.bashrc

or as your case

source ~/.bash_profile

For the Windows users check the global variables.

0
votes

Try to Run npm cache clean and re-install cordova...worked for me.