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

[CLI 3] Error trying to add android platform

Open theunreal opened this issue 9 years ago • 18 comments

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

theunreal avatar May 30 '17 15:05 theunreal

Can you try cordova platform add [email protected] ?

imhoffd avatar May 30 '17 20:05 imhoffd

@dwieeb, I get the same error in this version and any other

theunreal avatar May 31 '17 09:05 theunreal

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?

imhoffd avatar Jun 01 '17 18:06 imhoffd

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

madsongr avatar Aug 06 '17 21:08 madsongr

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

Cdvalencia avatar Oct 09 '17 16:10 Cdvalencia

thanks @Cdvalencia it works for me.

update: but it was failed ! :(

nhoangdieu avatar Nov 16 '17 08:11 nhoangdieu

Thank you madsongr, that solved my issue!!!

darrencole avatar Apr 08 '18 02:04 darrencole

I am having the same problem. Neither of solution have worked. What can I do?

mhbt avatar May 15 '18 14:05 mhbt

@darrencole What you did to solve this issue?

mhbt avatar May 15 '18 14:05 mhbt

@mhbt I did this: Try setting path = "C:\Windows\System32" in variable/system variable

darrencole avatar May 15 '18 15:05 darrencole

@darrencole how can write this in terminal ?

Amoioo avatar Feb 07 '19 21:02 Amoioo

@Amoioo what type of machine are you on?

darrencole avatar Feb 07 '19 22:02 darrencole

@darrencole windows os and visual studio code platform

Amoioo avatar Feb 08 '19 00:02 Amoioo

When I write this command (Ionic cordova build - - release android) this Error appears it is shown in attached picture. @darrencole @madsongr 0

Amoioo avatar Feb 08 '19 00:02 Amoioo

Ok. Try this. Go to Environment Variables on your PC and set the 'system variable' as we discussed above.

darrencole avatar Feb 08 '19 00:02 darrencole

How please Explain ? @darrencole

Amoioo avatar Feb 08 '19 11:02 Amoioo

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.

darrencole avatar Feb 08 '19 17:02 darrencole

image i can't do it

Supadtra avatar Nov 14 '19 07:11 Supadtra