3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cordova(Android)のCLIでVM Heap Errorが出たとき

3
Posted at

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

対処

  1. (CordovaProject)/(ProjectName)/platforms/android/cordova/lib/build.jsを開く。
  2. こちらの記事を参考に、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);
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?