Sergej
Sergej

Reputation: 2176

Error adding platform android: ShellCommandError: Non-zero exit from subprocess

What is the problem? I am trying to add android platform for my application. I were using Ionic 3.2.0 earlier. Now it's Ionic 4.0.1. I have tried to downgrade ionic back to 3.2.0, and then add platform, but it says, cordova - unknown command lol, whats have happend?

Here is the output:

...
Installing "cordova-plugin-file-transfer" for android
Plugin dependency "[email protected]" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Adding cordova-plugin-file-transfer to package.json
Saved plugin info for "cordova-plugin-file-transfer" to config.xml
Discovered plugin "cordova-plugin-filepath" in config.xml. Adding it to the project
Installing "cordova-plugin-filepath" for android
Adding cordova-plugin-filepath to package.json
Saved plugin info for "cordova-plugin-filepath" to config.xml
Discovered plugin "com-sarriaroman-photoviewer" in config.xml. Adding it to the project
Failed to restore plugin "com-sarriaroman-photoviewer" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin com-sarriaroman-photoviewer@^1.1.18 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module
Discovered plugin "cordova-plugin-geolocation" in config.xml. Adding it to the project
Installing "cordova-plugin-geolocation" for android
Adding cordova-plugin-geolocation to package.json
Saved plugin info for "cordova-plugin-geolocation" to config.xml
Discovered plugin "cordova-plugin-insomnia" in config.xml. Adding it to the project
Installing "cordova-plugin-insomnia" for android
Adding cordova-plugin-insomnia to package.json
Saved plugin info for "cordova-plugin-insomnia" to config.xml
Discovered plugin "cordova-plugin-firebase" in config.xml. Adding it to the project
Installing "cordova-plugin-firebase" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-firebase to package.json
Saved plugin info for "cordova-plugin-firebase" to config.xml
Preparing Firebase on Android
--save flag or autosave detected
Saving android@~7.0.0 into config.xml file ...
[ERROR] ShellCommandError: Non-zero exit from subprocess. { name: 'ShellCommandError', code:
        'ERR_ICF_SHELL_NON_ZERO_EXIT', exitCode: 1, signal: undefined } Error

             at new BaseError
        (C:\Users\volkk\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-framework\errors.js:15:23)
             at new ShellCommandError
        (C:\Users\volkk\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-framework\errors.js:47:9)
             at ChildProcess.p.on
        (C:\Users\volkk\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-framework\utils\shell.js:99:33)
             at emitTwo (events.js:126:13)
             at ChildProcess.emit (events.js:214:7)
             at ChildProcess.cp.emit
        (C:\Users\volkk\AppData\Roaming\npm\node_modules\ionic\node_modules\cross-spawn\lib\enoent.js:40:29)
             at maybeClose (internal/child_process.js:925:16)
             at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

Ionic Info:

C:\Users\volkk\Desktop\CargoTenderApp>ionic info

Ionic:

   ionic (Ionic CLI)  : 4.0.1 (C:\Users\volkk\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            : v8.9.4 (C:\Program Files\nodejs\node.exe)
   npm               : 5.6.0
   OS                : Windows 10

Environment:

   ANDROID_HOME : C:\android

Upvotes: 2

Views: 4347

Answers (3)

Rudda Beltrao
Rudda Beltrao

Reputation: 37

This works for me:

npm i -g cordova

cordova not has been instaled into my machine

Upvotes: 0

Artur Kedzior
Artur Kedzior

Reputation: 4263

Similar problem. Just before throwing this error I had:

Failed to restore plugin "cordova-plugin-facebook4" from config.xml

Reference to this package exists in package.json and config.xml and points to github repo.

Since the reference is already in config.xml removing it from package.json did the trick.

"cordova-plugin-facebook4": "git+https://github.com/Bilbayt/cordova-plugin-facebook4.git",

It only happens on Windows.

Upvotes: 0

Gayan Kalhara
Gayan Kalhara

Reputation: 755

I got the same issue today. After trying few things it got fixed. Not sure what caused this.

Can you try these steps.

First of all perform a clean npm install after removing node_modules, platforms and plugins directories. Then run the following commands.

  1. Run the command.

    ionic cordova platform remove ios --save

  2. Run the command

    ionic cordova platform remove android --save

  3. Add iOS platform back

    ionic cordova platform add ios --save

  4. Add Android Platform back

    ionic cordova platform add android --save

Also try updating @ionic/app-scripts to version 3.1.11

Upvotes: 5

Related Questions