Error when i build my apk file

#1
cordova build android --optimizejs --minifycss --minifyjs --ant
Android Studio project detected
ANDROID_HOME=C:\Users\la tontantine\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio

BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

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/4.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.

* Get more help at https://help.gradle.org
(node:10060) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 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/4.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.

* Get more help at https://help.gradle.org
PS E:\ionic\projet\schoolSearch> please help
#2

You don’t seem to have enough RAM for this to be executed.

What is your ionic info output?

#3
ionic cordova build android --optimizejs --minifycss --minifyjs --info
> ionic-app-scripts build --minifyjs --minifycss --optimizejs --platform android
[10:49:16]  ionic-app-scripts 3.1.10
[10:49:16]  build dev started ...
[10:49:17]  clean started ...
[10:49:17]  clean finished in 138 ms
[10:49:17]  copy started ...
[10:49:19]  deeplinks started ...
[10:49:19]  deeplinks finished in 201 ms
[10:49:19]  transpile started ...
[10:49:46]  transpile finished in 26.51 s
[10:49:46]  preprocess started ...
[10:49:46]  preprocess finished in 3 ms
[10:49:46]  webpack started ...
[10:49:49]  copy finished in 31.90 s
[10:50:20]  webpack finished in 34.69 s
[10:50:20]  uglify started ...
[10:50:21]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[10:50:36]  sass finished in 15.82 s
[10:50:36]  cleancss started ...
[10:50:56]  cleancss finished in 19.62 s
[10:51:56]  uglify finished in 95.09 s
[10:51:56]  postprocess started ...
[10:51:56]  postprocess finished in 49 ms
[10:51:56]  lint started ...
[10:51:56]  build dev finished in 159.37 s
[10:52:26]  tslint: E:/ionic/projet/schoolSearch/src/pages/details/details.ts, line: 3
            'Headers' is declared but its value is never read.

       L2:  import { IonicPage, NavController, NavParams } from 'ionic-angular';
[10:52:27]  tslint: E:/ionic/projet/schoolSearch/src/pages/details/details.ts, line: 3
       L3:  import {Http ,Headers, RequestOptions } from '@angular/http'
       L4:  import 'rxjs/add/operator/map';

            'RequestOptions' is declared but its value is never read.

       L2:  import { IonicPage, NavController, NavParams } from 'ionic-angular';
       L3:  import {Http ,Headers, RequestOptions } from '@angular/http'
       L4:  import 'rxjs/add/operator/map';

[10:52:27]  lint finished in 30.94 s
> cordova build android
Android Studio project detected
ANDROID_HOME=C:\Users\la tontantine\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

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/4.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.

* Get more help at https://help.gradle.org
(node:10312) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 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/4.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.

* Get more help at https://help.gradle.org


   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 4.0.0 → 4.0.6    │
   │    Run npm i -g ionic to update     │
   │                                     │
   ╰─────────────────────────────────────╯here is the answer with the --info option
#4

That is the exact same thing as before.

Just run ionic info in your project.

#5

Ionic:

ionic (Ionic CLI) : 4.0.0 (C:\Users\la tontantine\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.10

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0

System:

Android SDK Tools : 26.1.1
NodeJS : v6.11.1 (C:\Program Files\nodejs\node.exe)
npm : 3.10.10
OS : Windows 10

Environment:

ANDROID_HOME : C:\Users\la tontantine\AppData\Local\Android\Sdk

#6

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

But the actual problem is still the same:

#7

how many ram are needed to run it?? please

#8

It seems to try to reserve 2 GB (2097152 kB = 2048 Mb = 2 Gb).

#9

how can I book 2G ram since the ram is 4GB,
I even restart the machine and I launch no program even as his sa always shows me this absence of memory the

#10

Even if you manage to resort this error your PC may get hang as you should have at least have 8GB RAM[ Try with 6GM not sure about it]but 4GB definitely will cause some problem here and there. I faced this issue a lot but after upgrading RAM resolved without any change in project

#11

thank you for you answer