7

I installed cordova e phonegap via npm install -g cordova and npm install -g phonegap respectively. Then i created a HelloWorld application via cordova create HelloWorld mynamespace.helloworld HelloWorld. It worked fine! Then i changed my working directory to HelloWorld and i tried to build the app for android via cordova platform add android -d but it didn't work. here is the output:

Installing cordova library for android...
Requesting {"uri":"https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.3.0;sf=tgz"}...
Downloading cordova library for android...
Downloaded, unzipped and extracted 541065 byte response.
Download complete
Installing cordova library for android...
Checking if platform "android" passes minimum requirements...
Creating android project...
Running bin/create for platform "android" with command:     ""C:\Users\marcos.pacheco\.cordova\lib\android\cordova\3.3.0\bin\create"  "C:\Dev\HelloWorld\platforms\android" "mynamespace.helloworld" "HelloWorld"" (output to follow)


C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
                throw e;
                      ^
Error: An error occured during creation of android sub-project.

at C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\src\platform.js:244:30
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:787:12)

I've googled and have found some issues with whitespaces but my project is in the C:\Dev\HelloWorld path and my android sdk is in the PATH so that when i type adb at the windows prompt i get the help information of the command as well Java and Ant. Furthermore, i have ANT_HOME, JAVA_HOME and ANDROID_HOME set. I also deleted the ** .cordova ** folder inside my %HOMEPATH% directory and entered the command again but the error is still there.

What might be wrong?

mnatan.brito
  • 883
  • 5
  • 18
  • 32
  • What happens if you type "android" in the command line? Does it pop up the SDK manager and show you have the Tools and Platform-Tools installed? Can you type 'android" then Tools-->manage AVDs-->(create a new AVD if there is none there)? Did you add the `node_modules` directory to your path? – MBillau Dec 16 '13 at 21:05
  • @MBillau When i type android at the prompt, it shows the following message: ''xcopy' is not recognized as an internal or external command, operable program or batch file. ERROR: SWT folder 'lib\x86_64' does not exist. Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.' – mnatan.brito Dec 16 '13 at 21:17
  • 1
    Well XCOPY definitely needs to be found because it is used by a lot of those node.js files. If you type 'where xcopy' it should print out a file IF xcopy is installed. If you type `xcopy` and don't get anything, you will need to download the xcopy.exe from somewhere and then add it to your path. It's strange that you don't have xcopy installed though - maybe somehow it got deleted or was never added to your PATH. Can you paste your PATH variable please? – MBillau Dec 16 '13 at 21:35
  • @MBillau You're right xcopy was not in my PATH. I just added %SystemRoot%\System32 to the PATH and it worked! Now when i type android at the prompt, it opens the SDK Manager. – mnatan.brito Dec 17 '13 at 11:37
  • Great, can you do `cordova platform add android` now? You may need to create an AVD through the SDK manager. – MBillau Dec 17 '13 at 13:52
  • @MBillau Yes, now i'm able to issue `cordova platform add android` and to deploy my app to emulator as well. Thank you! – mnatan.brito Dec 17 '13 at 16:54

1 Answers1

2

XCOPY needs to be defined and found on your path as it is used by the internal node.js scripts to move things around.

You probably already have xcopy.exe somewhere on your machine. You should be able to add %SystemRoot%\System32 to your PATH and it will work. Or you can open up a terminal and type where xcopy to see the actual path to your xcopy.exe.

I guess having XCOPY on the path is a requirement for setting up and installing Android, but it'd be nice if Cordova checked to make sure you have XCOPY somewhere...

MBillau
  • 5,366
  • 2
  • 28
  • 29
  • Can u please explain it..? I'd `where xcopy` and found it in 'C:\Windows\System32\xcopy.exe`. So I appended `;C:\Windows\System32` in my PATH variable. But still getting same error. – shashwat Feb 17 '14 at 06:51
  • Hi @shashwat, are you sure you are getting the same error about xcopy? Are you using something special for your command line? can you echo the PATH in whichever you are using for a shell (mysgit, or cmd, or whatever) and see if it's the same PATH? If you are on Windows 7 it might matter which user (user or admin) you use to set the environment variable... – MBillau Feb 17 '14 at 14:37