ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Error: Failed to fetch platform cordova-android@^6.2.3 Probably this is either a connection problem, or platform spec is incorrect.

Open faziltm opened this issue 9 years ago • 19 comments

when i am using cordova ionic framework

My cordova version is 6.2.3 Node js version is 6.11.1

My android sdk in C:\Users\user3\AppData\Local\Android\Sdk I am using android studio my sdk api level is 25.

C:\Users\user3\Desktop\myApp>ionic cordova platform add android

cordova platform add android --save × Running command - failed!

[ERROR] Cordova encountered an error. You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android --save (exit code 1):

    Using cordova-fetch for cordova-android@^6.2.3
    Error: Failed to fetch platform cordova-android@^6.2.3
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: cmd: Command failed with exit code ENOENT

Please help me.

faziltm avatar Jul 19 '17 08:07 faziltm

What is you ionic info output?

Run the same command with --verbose at the end. Leave the ionic off at the beginning and add --debug at the end. Post both outputs.

janpio avatar Jul 21 '17 14:07 janpio

I've never seen this issue locally so I've been unable to reproduce the problem.

It's a Cordova CLI issue (not Ionic CLI). Something with the cache, maybe? There are a ton of google results: https://www.google.com/search?q=failed+to+fetch+platform+cordova-android&oq=failed+to+fetch+platform+cordova-android&aqs=chrome..69i57j0l3j69i61.709j0j7&sourceid=chrome&ie=UTF-8

Please update the issue if you find a solution.

imhoffd avatar Jul 21 '17 17:07 imhoffd

Nobody?

marosca avatar Sep 12 '17 19:09 marosca

I am under the impression that it happens less when node and npm was installed via nvm or nvm-windows. But I don't have proof. (But uninstalling node and reinstalling it via nvm or nvm-windows mostly fixes the problem...)

janpio avatar Sep 12 '17 19:09 janpio

Thanks for your advices, but I am under mac and I dont know what is nvm? What is it? Thank you!

Enviar desde Mi telefono El Jan Piotrowski [email protected], 12 sept. 2017 9:40 p. m. escribió:

I am under the impression that it happens less when node and npm was installed via nvm or nvm-windows. But I don't have proof. (But uninstalling node and reinstalling it via nvm or nvm-windows mostly fixes the problem...)

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ionic-team/ionic-cli/issues/2538#issuecomment-328962717, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACbTBZ6Uawt_aAwZIPE0GshjNE906Brrks5sht47gaJpZM4OcZlR.

marosca avatar Sep 12 '17 20:09 marosca

https://github.com/creationix/nvm

janpio avatar Sep 12 '17 20:09 janpio

Thanks

Enviar desde Mi telefono El Jan Piotrowski [email protected], 12 sept. 2017 10:44 p. m. escribió:

https://github.com/creationix/nvm

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ionic-team/ionic-cli/issues/2538#issuecomment-328978943, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACbTBUv_pUVECkoGDd2yVxeAyI3Yn7Ooks5shu0wgaJpZM4OcZlR.

marosca avatar Sep 13 '17 00:09 marosca

Quick Fix -

DELETE the downloaded file cordova-android-6.2.3.tgz or folder npm-304 8-83f48a6f under- C:\Users**{userName}**\AppData\Local\Temp\npm-304 8-83f48a6f\registry.npmjs.org\cordova-android-\cordova-android-6.2.3.tgz

And do cordova platform add android again. npm will redownload the required file. You can also download it manually (7.7 MB) from here and place it in the same folder and then run the command.

or delete all the files in the temp folder add the downloaded file in the root folder of C:\Users**{userName}**\AppData\Local\Temp\cordova-android-6.2.3.tgz

Worked For Me

Namatai avatar Sep 21 '17 13:09 Namatai

Thanks, but I am under macos, do you know the file path? Thank you

Enviar desde Mi telefono El Samuel Namatai [email protected], 21 sept. 2017 3:37 p. m. escribió:

Quick Fix -

DELETE the downloaded file cordova-android-6.2.3.tgz or folder npm-304 8-83f48a6f under- C:\Users**{userName}**\AppData\Local\Temp\npm-304 8-83f48a6f\registry.npmjs.org\cordova-android-\cordova-android-6.2.3.tgz

And do cordova platform add android again. npm will redownload the required file. You can also download it manually (7.7 MB) from herehttp://registry.npmjs.org/cordova-android/-/cordova-android-6.2.3.tgz and place it in the same folder and then run the command.

or delete all the files in the temp folder add the downloaded file in the root folder of C:\Users**{userName}**\AppData\Local\Temp\cordova-android-6.2.3.tgz

Worked For Me

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ionic-team/ionic-cli/issues/2538#issuecomment-331158542, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACbTBRUmmdkl9Ntm3_1owT3wN2-vwH3cks5skmaIgaJpZM4OcZlR.

marosca avatar Sep 21 '17 14:09 marosca

apparently, npm or node tries to run "/usr/bin/node" "/my/project/node_modules/.bin/npm" "install" "cordova-android@~6.2.2" "--save" which fails for some reason. specifying cordova/ionic directly worked(-around) for me /usr/bin/cordova platform add android I have no idea about the underlying issue though...

edit: forgot to mention (thanks @dblazeski), tested on macos&arch node8.5.0/npm8.3.0/cordova7.0

f4bio avatar Sep 26 '17 06:09 f4bio

For me on mac, following f4bio comment, running just cordova platform add android fixed the issue, after that ionic cordova run android worked as expected

dblazeski avatar Sep 27 '17 17:09 dblazeski

Facing the same issue.

Hello... My greetings to you.

Am Gerald Kibirango an ionic lover and developer. I thank you for your services on improving ionic time to time and sharing with the community.

Am requesting for tour help. I created an ionic project, run it using the (ionic serve --lab) and it run well in the browser. Then wanted to and android platform to it after setting the path in the system variable very well with a confirmation of running a command (android) in the cmd and it opened the sdk (However for eclipse).

The run the command for adding android platform as (## ionic platform add android) and it failed, Then aslo run with (## ionic cordova platform add android) and also failed too.

It displayed the following error: ERROR Exception: Using cordova-fetch for cordova-android~6.3.0 Error: Failed to fetch platform cordova-android~6.3.0 probably this is either a connection problem, or platform spec is incorrect. Check your connection and platform name/version/uURL. Error: cmd: Command failed woth exit code ENOENT

May you help me. I will be glad for your response. Thanks

capitalgerald avatar Oct 20 '17 08:10 capitalgerald

Post this at the community forum please: https://forum.ionicframework.com/ Github issues are for bugs, not problems or questions.

janpio avatar Oct 20 '17 10:10 janpio

Hello members it seems like i have got the answer.....

Here it is

If you are in Windows usually this kind of error happens when you don't have all the paths required in your system environment path variable . Especially the path variables given bellow.

Please paste this line on your system environment Path variable:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Windows\System32;

Then close the current cmd and open a new cmd

Visit Here

capitalgerald avatar Oct 20 '17 10:10 capitalgerald

Ok Jan

Thanks

On Fri, Oct 20, 2017 at 1:13 PM, Jan Piotrowski [email protected] wrote:

Post this at the community forum please: https://forum.ionicframework.com/ Github issues are for bugs, not problems.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-cli/issues/2538#issuecomment-338166063, or mute the thread https://github.com/notifications/unsubscribe-auth/AbWWoN2Ehh5Mc_LWJdlJWdNrWrl9ujQWks5suHIwgaJpZM4OcZlR .

-- Tel : +256 751 068 163 Email : [email protected] Twitter : @capitalgerald Facebook : Capital Gerald

https://www.facebook.com/capital.gerald

capitalgerald avatar Oct 20 '17 13:10 capitalgerald

I am on Linux which is more or less like a MacOS when it comes to paths. Any idea what can be wrong?

kemety avatar Jan 17 '18 15:01 kemety

on Windows, deleting AppData/Temp files did the trick as @marosca and @Namatai suggested!

sirdowan avatar Feb 13 '18 11:02 sirdowan

Thank you capitalgerald. Adding "C:\Windows\System32" was sufficient for me.

darrencole avatar Apr 08 '18 02:04 darrencole

its work for me %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Windows\System32;

thanks so much!

placecodex avatar Jun 24 '18 06:06 placecodex