简体   繁体   中英

cordova platform add android error on Windows 8

I am using phonegap and have just started going through this tutorial here .

I am trying to add Android platform and getting this error:

C:\Users\Manu>cd hello

C:\Users\Manu\hello>cordova platform add android
Creating android project...

C:\Users\Manu\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\q.js
 :126
                throw e;
                      ^
Error: ERROR : executing command 'ant', make sure you have ant installed and added to your path.
at C:\Users\Manu\.cordova\lib\android\cordova\3.5.0\bin\lib\check_reqs.js:47:27
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Socket.<anonymous> (child_process.js:966:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Manu\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)

How can I fix this?

Your problem is actually the adt path is not recognised, follow below steps.

I am sharing with you the steps to create android PhoneGap app with cordova 3.4 version :-

1) Download and install Node.js.

2) Run this command on your terminal :-

$ sudo npm install -g cordova

3) Then create your project using following command :-

$ cordova create hello com.example.hello HelloWorld

4) Then before adding any platform , run the following command....Replace the path of android sdk with your system path :-

$ export PATH=${PATH}:/Users/taruna/Documents/adt-bundle-mac-x86_64-20131030/sdk/platform-tools:/Users/taruna/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools

5) Now add your platform using following command :-

 $ sudo cordova platform add android

6) Now you can successfully run your project on emulator using following command :-

 $ cordova emulate android

And its done now.

You are missing an Apache Ant installation.

  1. Install Ant --> link
  2. Set environment variable ANT_HOME which points to the bin directory of your installation path
  3. add this variable to your PATH environment variable

That should fix your problem.

I had the same issue and found out that it was due to a bug in Ant . My Classpath ended with a " too, and I had to fix this by updating my class path. Instead of:

"C:\Program Files\Something\here"

I used:

C:\Progra~1\Something\here

and now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM