Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cordova - Error: Failed to fetch platform android

I installed cordova and create a new project.

But when I use this command to add android platform:

cordova platform add android

this error appears:

Error: Failed to fetch platform android 
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: version not found: [email protected]

This is how I created the new project:

cordova create hello com.example.hello HelloWorld

And this is my SDK Manager:

SDK Manager

But I can add ios platform (But I work on Windows)

like image 744
Paili Avatar asked Feb 17 '16 08:02

Paili


4 Answers

I had the same problem with the [email protected] version. I solved this issue, checking what version of android is provided by cordova. You can check it in C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android

Then, you install the android platform version provided. For me it was @5.1.0 which was in my cordova-android folder. So I used the cmd line following:

cordova platform add [email protected] which should be a differnet version for you.

Kind regards !

like image 165
Lounes Avatar answered Sep 19 '22 15:09

Lounes


Had the same issue after using nvm to switch node version. Just removing android platform and reinstalling it works for me:

cordova platform rm android && cordova platform add android 
like image 38
Proustibat Avatar answered Sep 22 '22 15:09

Proustibat


you can check the android version provided by cordova by typing cordova platform ls inside projectname/cordova folder. I refered from below url https://cordova.apache.org/docs/en/latest/guide/platforms/android/.
(For me .cordova/lib folder was empty).

Then add that platform from inside project's cordova folder by executing cordova platform add [email protected] (in my case, solved the issue).

like image 25
venkhat Avatar answered Sep 20 '22 15:09

venkhat


In my case after so many attempts, I solved the issue by running this command:

sudo npm install [email protected] -g 

Then I was able to add platform and build my project.

like image 39
Kasim Ridwan Avatar answered Sep 19 '22 15:09

Kasim Ridwan