Impossible to add android platform to an ionic project

hello,
i have a problem when i try to add android platform to my ionic 2 project by running this following command:

ionic platform add android

i get this errors

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.
Error: cmd: Command failed with exit code ENOENT

can you tell me please what’s wrong with my project

hi elhabia, never saw that error sorry.

maybe you node server is just too old, try to upgrade node.js on your computer.
like npm upgrade or npm update

i have just installed npm yesterday. so i think my version is up to date

a dumb question, do you try to update a project folder from ionic v1 to ionic v3?
It won’t work whaetver the quality of your code. You must do a fresh start with Ionic 2 or Ionic 3 blank page.
Also, note that scope root variables just don’t exist starting ionic 2+

no my project version is ionic 2

Maybe

or

?

i have delete my .cordova folder and tried again to add an android platform to my project but i always have the same errors

this is odd sorry, i’ll think about it while coding. No errors related to jdk sure? (Android SDK). Can you push us the error log please?

Maybe?

npm cache clean

and then

ionic platform rm android
ionic platform add android@latest

and if still problem maybe install latest cordova first?

npm uninstall -g cordova
npm cache clean
npm install -g cordova@latest

and then remove/add the platform again

ionic platform rm android
ionic platform add android@latest

but well just some ideas…

1 Like

@reedrichards yes a good
npm -g cordova@latest should do be it
But I suspect something else is wrong :frowning:

Ah ! use —save on the project too

for instance ionic platform add android --save

and same for each ionic native plugin you use :slight_smile:
if you don’t, it will just be temporarily added to your files.

i have tried all what you have told me guys but i end up in the same errors as always.

i think that maybe there is something wrong with my android sdk or jdk.

can you tell me wat things i should check so to be sure that i have the right configuration.
thanks :slight_smile:

Well I trust you know how to check your environment, I’m a bit clueless too :frowning:

Well, you can try updating Java before Android (install it like there on Oracle corporate website:
http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Because of course, if your Java version is funky, ionic run won’t work well.

After, I’m totally out of ideas for your issues, you know how to check your info obvisouly;

After, ionic is pretty much self contained and install all dependencies in general (99% times). Yes maybe if you did work with Angular or so before on Windows, reinstall to try.

An issue i had once, is Android was not knowing where is the location of JDK (it changes between some versions). There is a thread on this forum I answered about it, you can dig on the forum with my name @FrancoisIonic.Sorry can’t find the topic number, it was like 4 monthes ago.

Good luck !:

could you show us the result of following cmds:

ionic info

and

cordova  -v

about android sdk, do you have a mac or windows os?

if mac, could you check that the application “Android Studio” is installed in the root folder of the applications, not in a subfolder (I had once a strange side effect because of that)

that’s what i got when i run ionic info

 ordova CLI: 7.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not - installed
OS: Windows 7
Node Version: v6.10.3
Xcode version: Not installed

and for cordova -v it give me

7.0.1

i’m in windows 7 Professionnel and yes i have android studio installed in the following path

C:\Program Files\Android\Android Studio\bin

i don’t think that android studio don’t know the location of JDK because if so i would get an error when i open it but i don’t

@FrancoisIonic i will search for the topic you mentionned and i will tell what i found
thanks guys :slight_smile:

@elhabia would you like to have a try running:

ionic platform add android --nofetch 

Reference: Windows 10 problem but who knows … https://issues.apache.org/jira/browse/CB-12767

1 Like

it worked guys.
i have just added

C:\Windows\System32

to my PATH variable to fix this odd issue.

thank you very much for your precious help :+1:

3 Likes

Awesome @elhabia congrats!

1 Like

OK Lol, Glad you fixed it.
Windows environment variables, are hell :rage: Found back the topic I spoke about meanwhile, it was also a windows environment variable issue (issue with PATH).

1 Like