I'm trying to add the android platform to my project using ionic cordova platform add android
and I get the following error:
c:\xampp\htdocs\myproj>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):
Error: Current working directory is not a Cordova-based project.
I tried to run cordova platform add android --save as the error refers, and I get the following error:
c:\xampp\htdocs\myproj>cordova platform add android --save
Using cordova-fetch for cordova-android@~6.2.2
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.
Failed to get absolute path to installed module
adding android platform in the CLI 3
Steps to reproduce:
ionic cordova platform add androidPost the output of ionic info below please
global packages:
@ionic/cli-utils : 1.2.0
Cordova CLI : 7.0.1
Ionic CLI : 3.2.0
local packages:
@ionic/app-scripts : 1.3.7
@ionic/cli-plugin-cordova : 1.2.1
@ionic/cli-plugin-ionic-angular : 1.2.0
Cordova Platforms : none
Ionic Framework : ionic-angular 3.3.0
System:
Node : v6.10.3
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
Can you try cordova platform add [email protected] ?
@dwieeb, I get the same error in this version and any other
I've never seen that error before. It says "Probably this is either a connection problem, or platform spec is incorrect."
We know the platform spec is correct, so what's your connection like?
Try setting path = "C:\Windows\System32" in variable/system variable
There seems to be an error with [email protected] and later. I had the same issue and using the below step was able to build my apk.
Do the following:
cordova platform remove android
Then add 6.1.2 specifically
cordova platform add [email protected]
Also found the following as an temporary workaround
cordova platform add android --nofetch
thanks @Cdvalencia it works for me.
update: but it was failed ! :(
Thank you madsongr, that solved my issue!!!
I am having the same problem. Neither of solution have worked. What can I do?
@darrencole What you did to solve this issue?
@mhbt I did this: Try setting path = "C:\Windows\System32" in variable/system variable
@darrencole how can write this in terminal ?
@Amoioo what type of machine are you on?
@darrencole windows os and visual studio code platform
When I write this command (Ionic cordova build - - release android) this Error appears it is shown in attached picture.
@darrencole @madsongr
Ok. Try this. Go to Environment Variables on your PC and set the 'system variable' as we discussed above.
How please Explain ? @darrencole
Sure buddy:
I hope this helps.

i can't do it
Most helpful comment
Try setting path = "C:\Windows\System32" in variable/system variable