CLI Version = 5.4.0
コマンドプロンプトでもそもそしてたら以下のエラーが出た。
C:\Users\User\Desktop\cordova_sample\sample\sample>cordova run android
(中略)
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 http://gradle.org/docs/2.2.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 object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
C:\Users\User\Desktop\cordova_sample\sample\sample\platforms\android\cordova\node_modules\q\q.js:12
6
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\User\Desktop\cordova_sample\sample\sample
platforms\android\gradlew cdvBuildDebug -b C:\Users\User\Desktop\cordova_sample\sample\sample\platf
orms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true"
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 8
You may not have the required environment or OS to run this project
対処
-
(CordovaProject)/(ProjectName)/platforms/android/cordova/lib/build.jsを開く。 -
こちらの記事を参考に、241行目あたりに
args.push('-Dorg.gradle.jvmargs=-Xms512m -Xmx1024m');を追加してあげる。
// 10 seconds -> 6 seconds
args.push('-Dorg.gradle.daemon=true');
args.push('-Dorg.gradle.jvmargs=-Xms512m -Xmx1024m'); // <- これを追加
args.push.apply(args, opts.extraArgs);