Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add platform using Cordova CLI 7.0.0

I updated my Cordova CLI from 6.5 to 7.0.0 using the command npm update -g cordova. I created a project( cordova create myApp com.myCompany.myApp myApp ). When I try to add Android to the project ( cordova platform add android ), i am getting the below error.

Error: Failed to fetch platform cordova-android@~6.2.2
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 1 Error output:
'C:\windows\system32\npm' is not recognized as an internal or external command,
operable program or batch file.

I also tried adding android with specific version which is available with CLI in my machine ( cordova platform add [email protected] ) but results the same.

Is there any special way to add platform tot he project with Cordova 7.0.0. ?

like image 578
Joseph Avatar asked May 10 '17 11:05

Joseph


People also ask

Which command is used to install plugin in cordova?

The cordova plugin add command requires you to specify the repository for the plugin code. Please note that when you follow the Web Project Dev workflow and use the CLI, the CLI will take care of adding the plugin code to the appropriate place for each platform.


2 Answers

I did some analysis on this and looks like its an issue with android SDK compatibility. Check for the version of Android provided by Cordova under C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android (in case of windows OS) and install the respective android platform version provided.

For example: cordova platform add [email protected]

Hope it helps. Cheers

UPDATE: I guess Issue-CB-12767 should resolve your issue. --nofetch is the key

like image 166
Gandhi Avatar answered Oct 06 '22 00:10

Gandhi


Running the following command in my project directory fixed the problem for me:

npm install
like image 31
Chong Lip Phang Avatar answered Oct 06 '22 00:10

Chong Lip Phang