0

cordova platfrom add android not working on Windows7. Its giving following error.

C:\Users\user\cordova_projects\myapp>cordova platforms add android

npm http GET https://registry.npmjs.org/cordova-android/3.6.4

npm http 304 https://registry.npmjs.org/cordova-android/3.6.4

Creating android project...

Error: C:\Users\user.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\cr

eate.bat: Command failed with exit code -1073741819

at ChildProcess.whenDone (C:\Users\user\AppData\Roaming\npm\node_modules\cor

dova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)

at ChildProcess.emit (events.js:98:17)

at maybeClose (child_process.js:756:16)

at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Utkarsh
  • 83
  • 2
  • 10

2 Answers2

1

This looks a path setting issue, I am too working on Window 7 and had similar issues initially when i had wrong path set. Plus there are no# of questions on SO where due to path have similar issues reported ...see this & this and this.

Here is how I set paths, so you check and set yours accordingly, hope will help you.

ANT_Home: C:\Program Files\apache-ant-1.9.4

Java_Home: C:\Program Files\Java\jdk1.7.0_60

ANDROID_HOME: C:\Android\AndroidSDK\sdk

and path variable references to three things:

path:.;C:\Program Files\nodejs\;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;

Community
  • 1
  • 1
AAhad
  • 2,805
  • 1
  • 25
  • 42
  • should i use variables like ANT_HOME JAVA_HOME ANDROID_HOME to store path then set these variable to PATH – Utkarsh Nov 26 '14 at 07:08
  • its no necessary but it makes easier to read. The purpose is to provide valid paths. – AAhad Nov 26 '14 at 07:16
  • I am having problem setting paths. i used setx PATH "%ANDROID_HOME%\bin" but its not working. – Utkarsh Nov 26 '14 at 07:33
  • %Android_Home%\bin is wrong !! there is no folder "bin" inside Android_Home ...see my path settings carefully – AAhad Nov 26 '14 at 07:34
  • I used **setx PATH "%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANT_HOME%\bin;"** – Utkarsh Nov 26 '14 at 07:41
  • ok, please share all variables path settings in your question above as I shared. – AAhad Nov 26 '14 at 07:42
  • My **ANDROID_HOME=C:\Program Files (x86)\Android\android-studio\sdk ANT_HOME=C:\Program Files\apache-ant-1.9.4** – Utkarsh Nov 26 '14 at 07:43
  • ANT_Home: C:\Program Files\apache-ant-1.9.4 Java_Home: C:\Program Files\Java\jdk1.7.0_05 ANDROID_HOME: C:\Program Files (x86)\Android\android-studio\sdk – Utkarsh Nov 26 '14 at 08:09
  • read the last answer -the correct marked one at end. it talks about xcopy.exe path http://stackoverflow.com/questions/21431363/error-while-adding-android-platform-for-cordova – AAhad Nov 26 '14 at 08:15
  • Now i am having this [problem](http://stackoverflow.com/questions/27144694/unable-to-run-node-on-cmd-windows-7) nothing is running on cmd. Though i have path set for every thing. – Utkarsh Nov 26 '14 at 08:50
  • Now its working. But saying to install Android target "android-19" – Utkarsh Nov 26 '14 at 09:28
  • ok good, now open Android SDK manager wizard and install the Android SDK 19. Because its trying to generate project on 19 which is currently not present on your machine. – AAhad Nov 26 '14 at 09:32
  • Okay. Thanks for the help. i have been trying to figure this out for last 6 days. – Utkarsh Nov 26 '14 at 09:50
  • you welcome, see if your other issues is resolved too, or update on that question – AAhad Nov 26 '14 at 09:58
0

You should try clearing the cache:

npm cache clean

oenpelli
  • 3,467
  • 2
  • 29
  • 20
  • i tried npm cache clean. but nothing changes still getting same error. – Utkarsh Nov 26 '14 at 04:43
  • Your listing for the problem looks a bit odd. A 304 response normally means that the android platform has already been added to this project. But then it attempts to create the android project which it will not do if it already exists. Also you are only displaying the error from the spawn process, normally you get an error listing from the actual script failure as well which may help identify what the actual error is. – oenpelli Nov 26 '14 at 22:54