[ERROR] An error occurred while running subprocess cordova

while running build command ionic cordova build android --verbose I am getting an error for Cordova due to I am not able to build apk of android

No scripts found for hook "after_compile".
No scripts found for hook "after_build".
[ERROR] An error occurred while running subprocess cordova.

        cordova build android --verbose exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
  ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms
  ionic:cli-framework:utils:process onBeforeExit handler: running 2 queued functions +1ms
  ionic:cli-framework:utils:process error while killing process tree for 25976: { Error: Command failed: taskkill /pid 25976 /T /F
  ionic:cli-framework:utils:process ERROR: The process "25976" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:275:12)
  ionic:cli-framework:utils:process     at emitTwo (events.js:126:13)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:214:7)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:925:16)
  ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 25976 /T /F' } +200ms
  ionic:cli-framework:utils:process Error from function 0 in exit queue: { Error: Command failed: taskkill /pid 25976 /T /F
  ionic:cli-framework:utils:process ERROR: The process "25976" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:275:12)
  ionic:cli-framework:utils:process     at emitTwo (events.js:126:13)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:214:7)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:925:16)
  ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 25976 /T /F' } +9ms
  ionic:cli-framework:utils:process error while killing process tree for 26156: { Error: Command failed: taskkill /pid 26156 /T /F
  ionic:cli-framework:utils:process ERROR: The process "26156" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:275:12)
  ionic:cli-framework:utils:process     at emitTwo (events.js:126:13)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:214:7)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:925:16)
  ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 26156 /T /F' } +165ms
  ionic:cli-framework:utils:process Error from function 1 in exit queue: { Error: Command failed: taskkill /pid 26156 /T /F
  ionic:cli-framework:utils:process ERROR: The process "26156" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:275:12)
  ionic:cli-framework:utils:process     at emitTwo (events.js:126:13)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:214:7)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:925:16)
  ionic:cli-framework:utils:process     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 26156 /T /F' } +5ms
  ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 1) +6ms

Details

Ionic:

   ionic (Ionic CLI) : 4.1.2 (C:\Users\Radamatic4\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework   : ionic1 1.2.4
   @ionic/v1-toolkit : 1.0.8

Cordova:

   cordova (Cordova CLI) : 7.1.0
   Cordova Platforms     : android 6.3.0
   Cordova Plugins       : no whitelisted plugins (18 plugins total)

System:

   Android SDK Tools : 26.1.1 (C:\Program Files (x86)\Android\android-sdk)
   NodeJS            : v8.9.1 (C:\Program Files (x86)\nodejs\node.exe)
   npm               : 5.6.0
   OS                : Windows 10
4 Likes

I have the same problem. Any update on this?

I also had this issue but ran “ionic cordova run android” and it pointed to the Gradle Daemon.

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

To resolve this I added a new environment variable to set the maximum heap size:
Name: _JAVA_OPTIONS
Value: -Xmx512M

It then made a fuss about not accepting license agreements for the Android SDK build tools so I ran this command from the C:\Program Files (x86)\Android\android-sdk\tools\bin directory.

sdkmanager --licenses

Accept each agreement.

same problem… any updates?

Same problem to me. Any updates?

1 Like

I had the same problem and solved it as follows:

  • First I deleted folder platforms (you can also move it to another place).
  • Executed ionic cordova platform add android.
  • After this ionic cordova build android worked again.