Cordova can't add android platform

Hello everyone.

Lately I’m seeing an error again and again. By that I mean if I try to add plugins or platforms I get the follwoing error:

cordova platform add android@latest --save
Using cordova-fetch for cordova-android@latest
Error: Failed to fetch platform cordova-android@latest
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Failed to get absolute path to installed module

It seems like ionic doesn’t find the git repositories of plugins or platforms anymore. This is very strange to me. Does anyone know would could be the cause for this?

Here is my ionic info:

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

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2


    ios-deploy : 1.9.2 
    ios-sim    : 6.0.0 
    Node       : v9.4.0
    npm        : 5.6.0 
    OS         : macOS High Sierra
    Xcode      : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set


    backend : pro

1 Like

hi , check if you have git in your machine , if it is installed just open your cmd console as administrator ,

1 Like

It is installed, this bug is still going on :frowning:

Ionic is not involved here, you get the same result when you call cordova platform add android. So the problem is either with Cordova, whatever cordova-fetch is using. As it works on my machine (and thousand others) right now, my guess is something on your machine is strange.

Does it work on a new project started with ionic start?

Yup, it works on new projects. But since this project is so big, it would be very bad having to redo everything in a new project…

If it works on a new project, this excludes your environment as the source for the problem. Which is a good thing. Now you “only” have to compare your project to a newly created one and see what is different.

Sometimes checking out the app newly from git also solves such problems.
Same for deleting node_modules and rerunning npm install.

1 Like

Tried both. I even used ionic cordova plugin remove and then add several times, doesn’t change it :confused:

How is this related to cordova platform add?

Well I removed anything that was there first using remove.
And then I used platform add to add it again :slight_smile: