Ionic-cli: [CLI 3] Error trying to add android platform

Created on 30 May 2017  Â·  18Comments  Â·  Source: ionic-team/ionic-cli

Short description of the problem:

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

What behavior are you expecting?

adding android platform in the CLI 3

Steps to reproduce:

  1. run ionic cordova platform add android

Post 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

Most helpful comment

Try setting path = "C:\Windows\System32" in variable/system variable

All 18 comments

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
0

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:

  1. Go to Control Panel > System > Advanced System Settings
  2. Click on the Advanced tab then press the "Environment Variables" button
  3. Go to the "System Variables" section and click on the "Path" variable.
  4. Click on edit.
  5. Append C:\Windows\System32 to the end of the Path value. Note, each new addition to Path must be separated from the last by a semi colon.

I hope this helps.

image
i can't do it

Was this page helpful?
0 / 5 - 0 ratings