Cordova can't add android platform


#1

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

System:

    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

Misc:

    backend : pro


#2

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


#3

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


#4

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?


#5

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…


#6

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.


#7

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


#8

How is this related to cordova platform add?


#9

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