Failed to restore plugin "cordova-plugin-statusbar" in ionic cordova platform add android

Hi, I just found interesting problem on Windows, when I tried to run

ionic cordova platform add android

I encountered error like this:

[

INFO] Enabling Cordova integration.
> ionic config set integrations.cordova {} --json --force
[OK] integrations.cordova set to {} in .\ionic.config.json!
> cordova platform add android --save
× Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-android@~6.2.2

        Adding android project...
        Creating Cordova project for the Android platform:
                Path: platforms\android
                Package: io.ionic.starter
                Name: MyApp
                Activity: MainActivity
                Android target: android-25
        Subproject Path: CordovaLib
        Android project created with cordova-android@6.2.3
        Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
        Installing "cordova-plugin-device" for android
        Adding cordova-plugin-device to package.json
        Saved plugin info for "cordova-plugin-device" to config.xml
        Discovered plugin "cordova-plugin-ionic-webview" in config.xml. Adding it to the project
        Installing "cordova-plugin-ionic-webview" for android
        Adding cordova-plugin-ionic-webview to package.json
        Saved plugin info for "cordova-plugin-ionic-webview" to config.xml
        Discovered plugin "cordova-plugin-splashscreen" in config.xml. Adding it to the project
        Installing "cordova-plugin-splashscreen" for android
        Adding cordova-plugin-splashscreen to package.json
        Saved plugin info for "cordova-plugin-splashscreen" to config.xml
        Discovered plugin "cordova-plugin-statusbar" in config.xml. Adding it to the project
        Failed to restore plugin "cordova-plugin-statusbar" from config.xml. You might need to try adding it again.
        Error: Failed to fetch plugin cordova-plugin-statusbar@https://github.com/apache/cordova-plugin-statusbar.git
        via registry.
        Probably this is either a connection problem, or plugin spec is incorrect.
        Check your connection and plugin name/version/URL.
        Error: cmd: Command failed with exit code 1 Error output:
        npm ERR! git clone
        C:\Users\Teerasej\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92
        C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd:
        Cloning into
        'C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd'...
        npm ERR! git clone
        C:\Users\Teerasej\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92
        C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd:
        error: cannot spawn sh: No such file or directory
        npm ERR! git clone
        C:\Users\Teerasej\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92
        C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd:
        fatal: unable to fork
        npm ERR! git clone
        C:\Users\Teerasej\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92
        C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd:

        npm ERR! code 128
        npm ERR! Command failed: git -c core.longpaths=true clone
        C:\Users\Teerasej\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92
        C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd
        npm ERR! Cloning into
        'C:\Users\Teerasej\AppData\Local\Temp\npm-9880-9f262878\git-cache-80e59b63\fff289c0b8a7d0eb5b94f06d8ace9733054185bd'...
        npm ERR! error: cannot spawn sh: No such file or directory
        npm ERR! fatal: unable to fork
        npm ERR!

        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\Teerasej\AppData\Roaming\npm-cache\_logs\2017-10-09T07_07_45_121Z-debug.log
        Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
        Installing "cordova-plugin-whitelist" for android

                        This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a
        previous platform version, you do *not* need this plugin since the whitelist will be built in.

        Adding cordova-plugin-whitelist to package.json
        Saved plugin info for "cordova-plugin-whitelist" to config.xml
        Discovered plugin "ionic-plugin-keyboard" in config.xml. Adding it to the project
        Installing "ionic-plugin-keyboard" for android
        Adding ionic-plugin-keyboard to package.json
        Saved plugin info for "ionic-plugin-keyboard" to config.xml
        --save flag or autosave detected
        Saving android@~6.2.3 into config.xml file ...

Internet Connection?

First, I guess it is about the internet connection. So I switch to new network, tried, and failed again. then I tried to new one, and failed again.

But in same network, same place, on MacOS. The addition just worked.

So I move to next.

Git?

I doubt that problem caused from Git version, currently is 2.14.2.window.1. But when I tried 2.13 and 2.0, all is 64-bit.

It’s still failed.

On the other hand, MacOS with git version 2.13.5 (Apple Git-94) just works.

What is real problem?

I remind that few weeks ago, with the same version of Git, same network. Everything still work.
Now I wonder what causes the problem? Git server? Cordova Registry?

FYI:

  1. I tried to install the plugin with ionic cordova plugin add, but still failed
  2. I used fresh created Ionic Project from ionic start command (Oct 9, 2017)

Ionic Info on MacOS that works

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 25.2.3
    ios-deploy        : 1.9.1
    ios-sim           : 6.0.0
    Node              : v6.9.2
    npm               : 3.10.9
    OS                : macOS Sierra
    Xcode             : Xcode 9.0 Build version 9A235

Misc:

    backend : pro

Ionic Info on Windows (Problem found here)


cli packages: (C:\Users\Teerasej\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 25.2.5
    Node              : v6.11.0
    npm               : 4.6.1
    OS                : Windows 10

Misc:

    backend : legacy
1 Like

I had the same problem. Upgrading npm fixed this for me.

BUILD SUCCESSFUL

Total time: 1.73 secs
Built the following apk(s):
android-debug.apk

ionic info

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 26.0.2
Node              : v6.11.4
npm               : 5.4.2
OS                : Windows 10

Misc:

backend : legacy


Also ran “npm update” in the app folder

1 Like

Hi,

i have exactly the same issue, the standard ionic cordova command can’t get a git clone,
BUT! if you use the:
cordova plugin add cordova-plugin-statusbar

the plugin will be installed without any error, and you can deploy the application.

Thank @ujhazi, I saw this solution worked for others. But not for me.

Anyway, for anyone who have this error. Should tried @ujhazi’s solution first. It might fix the problem. :slight_smile:

Hi @jharkinslamar. Thank a lot. Your solution works for me.

I will concluded The steps here for other:

  1. run npm install -g npm in terminal (or Command Prompt, PowerShell on Windows)
  2. run npm update in your Ionic project directory.

hello teerasej
I have same problem and stuck with these…

and why this error is suddenly comes…
till yesterday all thing going smooth but suddenly this error comes

Can you help please

when i tried to run cordova plugin add cordova-plugin-statusbar
again another error will comes.

Hey kumaron!

This worked for me:

cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git

4 Likes

@kumarom following steps solved my problem.

  1. run npm install -g npm in terminal (or Command Prompt, PowerShell on Windows)
  2. run npm update in your Ionic project directory.

hi @teerasej
Iam having the same issue and not solved with your solution.:expressionless:

Do you have any suggestion.

ionic info
@ionic/cli-utils : 1.13.0
ionic (Ionic CLI) : 3.13.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.3.0
Ionic Framework    : ionic-angular 3.7.1

System:

Node : v6.10.0
npm  : 5.4.2
OS   : Windows 10

Thanks,

I have the same issue :cry:

cli packages: (/bitrise/src/node_modules)
    @ionic/cli-utils  : 1.13.1
    ionic (Ionic CLI) : 3.13.1
global packages:
    cordova (Cordova CLI) : 7.1.0 
local packages:
    @ionic/app-scripts : 3.0.0-201710161925
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.7.1-201710101557
System:
    Android SDK Tools : 26.1.1
    Node              : v8.7.0
    npm               : 5.5.1 
    OS                : Linux 4.4
Misc:
    backend : pro

And error like you.

$ ionic "cordova" "platform" "add" "android"
> cordova platform add android --save
✖ Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-android@~6.3.0
        Adding android project...
        Creating Cordova project for the Android platform:
        	Path: platforms/android
        	Package: io.ionic.conferenceapp
        	Name: Ionic_Conference
        	Activity: MainActivity
        	Android target: android-26
        Subproject Path: CordovaLib
        Android project created with cordova-android@6.3.0
        Discovered plugin "cordova-plugin-crosswalk-webview" in config.xml. Adding it to the project
        Installing "cordova-plugin-crosswalk-webview" for android
        Subproject Path: CordovaLib
        
                 After much discussion and analysis of the market, we have decided to discontinue support for Android 4.0 (ICS) in Crosswalk starting with version 20.
        
                 So the minSdkVersion of Cordova project is configured to 16 by default.
            
        Adding cordova-plugin-crosswalk-webview to package.json
        Saved plugin info for "cordova-plugin-crosswalk-webview" to config.xml
        Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
        Installing "cordova-plugin-device" for android
        Adding cordova-plugin-device to package.json
        Saved plugin info for "cordova-plugin-device" to config.xml
        Discovered plugin "cordova-plugin-inappbrowser" in config.xml. Adding it to the project
        Installing "cordova-plugin-inappbrowser" for android
        Adding cordova-plugin-inappbrowser to package.json
        Saved plugin info for "cordova-plugin-inappbrowser" to config.xml
        Discovered plugin "cordova-plugin-splashscreen" in config.xml. Adding it to the project
        Installing "cordova-plugin-splashscreen" for android
        Adding cordova-plugin-splashscreen to package.json
        Saved plugin info for "cordova-plugin-splashscreen" to config.xml
        Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
        Installing "cordova-plugin-whitelist" for android
        
                        This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
                  
        Adding cordova-plugin-whitelist to package.json
        Saved plugin info for "cordova-plugin-whitelist" to config.xml
        Discovered plugin "cordova-plugin-ionic-webview" in config.xml. Adding it to the project
        Installing "cordova-plugin-ionic-webview" for android
        Adding cordova-plugin-ionic-webview to package.json
        Saved plugin info for "cordova-plugin-ionic-webview" to config.xml
        Discovered plugin "cordova-plugin-ionic-wkkeyboard" in config.xml. Adding it to the project
        Installing "cordova-plugin-ionic-wkkeyboard" for android
        Adding cordova-plugin-ionic-wkkeyboard to package.json
        Saved plugin info for "cordova-plugin-ionic-wkkeyboard" to config.xml
        Discovered plugin "cordova-plugin-statusbar" in config.xml. Adding it to the project
        Failed to restore plugin "cordova-plugin-statusbar" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin git+https://github.com/apache/cordova-plugin-statusbar.git 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
        --save flag or autosave detected
        Saving android@~6.3.0 into config.xml file ...
        
command failed, error: exit status 1

I tried to build the ionic-conference-app. https://github.com/ionic-team/ionic-conference-app
So I think this should normally work.

What can I do? Thanks in Advance for any ideas / hints.

I have the same problem with plugins added from Github repository. I debugged and figured out that its was occurring with 7.1.0 Cordova version (Cordova CLI). Downgrade Cordova (Cordova CLI) to version 7.0.1 and everything should works fine.

2 Likes

Thanks @feliperfmarques!
Downgrade Cordova (Cordova CLI) to version 7.0.1 and everything works fine.
npm install -g cordova@7.0.1

1 Like

Use cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git and this works. Dont need to downgrade to Cordova 7.0.1.

More info:

For me also its worked