SPA Developer
SPA Developer

Reputation: 221

Can't run PhoneGap's create command

I am trying to setup a basic "hello world" PhoneGap project. I've been walking through the steps found at http://docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android. I am doing this on a Windows 7 Ultimate machine.

I have successfully setup Java and Ant. I have confirmed this by typing "javac -version" in a command prompt (1.6.0_39 is shown). When I type "ant" in a command prompt, I receive a message that says "Buildfile: build.xml does not exist! Build failed". At this point, I'm confident I've done everything properly through step 3. However, when I get to step 4, I run into issues.

On step 4 when I type "create C:\Tests\Android Test MyNamespace.Test.Android" in a command prompt, I receive an error that says: "create is not recognized as an internal or external command, operable program or batch file.". What could be wrong? Where does "create" come from? I'm in the /Cordova/phonegap-2.7.0/phonegap-2.7.0/lib/android directory when I run the command, I receive the following error:

Creating new android project...
Copying template files...
Copying js, jar & config.xml files...
Copying cordova command tools...
Updating AndroidManifest.xml and Main Activity...
C:\Program Files\Cordova\phonegap-2.7.0\phonegap-2.7.0\lib\android\bin\create.js
(31, 5) Microsoft JScript runtime error: Path not found

I can see the create.js file. However, for some reason I'm getting this "Path not found" error. Did I enter an incorrect command prompt parameter? I keep staring at it and everything looks correct.

Thank you!

Upvotes: 2

Views: 5493

Answers (6)

Fiach Reid
Fiach Reid

Reputation: 7069

It looks like the project name cannot have dots in it.

C:\Phonegap\android\bin>create c:\android\helloworld3 com.hello.world helloworld

Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

C:\Phonegap\android\VERSION Creating new android project... Copying template files... Copying js, jar & config.xml files... Copying cordova command tools... Updating AndroidManifest.xml and Main Activity... c:\android\helloworld3\src\com\hello\world\helloworld.java c:\android\helloworld3\src\com\hello\world\helloworld.java c:\android\helloworld3\AndroidManifest.xml c:\android\helloworld3\AndroidManifest.xml c:\android\helloworld3\AndroidManifest.xml

(works ok)

But...

C:\Phonegap\android\bin>create c:\android\helloworld4 com.hello.world hello.world

Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

C:\Phonegap\android\VERSION Creating new android project... Copying template files... Copying js, jar & config.xml files... Copying cordova command tools... Updating AndroidManifest.xml and Main Activity... c:\android\helloworld4\src\com\hello\world\hello.world.java C:\Phonegap\android\bin\create.js(32, 5) Microsoft JScript runtime error: Path not found (fails)

Unhelpful error message though.

Upvotes: 0

Check your environment path:

Set Environment variables:

Path:
Start -> Control Panel -> System and Security -> System -> Environment variables 

Or

Mycomputer -> Right Click -> properties -> Advance System settings -> Environment variables

1. Java JDK
2. Android SDK
3. ANT

User variables for user1: Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Users\user1\AppData\Roaming\npm\

Temp: %USERPROFILE%\AppData\Local\Temp

System variables:

ANDROID_HOME: C:\Nithi\software\Android_sdk\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\ Path:

ANT_HOME: C:\ant

JAVA_HOME: C:\Program Files\Java\jdk1.7.0_45\

JAVA_PATH: C:\Program Files (x86)\Java\jre7\bin

Path: c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\nodejs\;%ANT_HOME%\bin;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Upvotes: 2

magua
magua

Reputation: 69

Same problem here... Strangely if I run the comand "Create" with no parameters, it creates a folder "example" with a sample app, without the error

I found the answer in: https://groups.google.com/d/msg/phonegap/tnz2DnUE-E0/ADZibhwHGpYJ

The problem is with this line in "create.js":

var ACTIVITY_PATH=PROJECT_PATH+'\\src\\'+PACKAGE_AS_PATH+'\\'+ACTIVITY+'.java';
[...]
exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\project\\Activity.java '+     ACTIVITY_PATH +' /Y');

The Windows "copy" command will not create directories that don't exist, so the command above fails because "src\PACKAGE_AS_PATH" doesn't exist. This can be fixed with:

var ACTIVITY_DIR=PROJECT_PATH + '\\src\\' + PACKAGE_AS_PATH;
var ACTIVITY_PATH=ACTIVITY_DIR+'\\'+ACTIVITY+'.java';
[...]
exec('%comspec% /c mkdir ' + ACTIVITY_DIR);
exec('%comspec% /c copy "' + ROOT + '"\\bin\\templates\\project\\Activity.java ' +  ACTIVITY_PATH + ' /Y');

Upvotes: 2

Shyru
Shyru

Reputation: 11

I think you should put your path to the project directory in "" otherwise the create script will interpret "Test" as the package name, which is obviously not a valid package name. So command should read:

create "C:\Tests\Android Test" MyNamespace.Test.Android AndroidTest

Upvotes: 0

MBillau
MBillau

Reputation: 5376

You should be in Cordova/phonegap-2.7.0/phonegap-2.7.0/lib/android/bin directory. Then type: create {path} {project.with.dots} {YourProjectName}.

For example, I just ran: C:\server\cordova\phonegap-2.7.0\phonegap-2.7.0\lib\android\bin> create ../MyTest my.test.com MyTestProject and it created MyTest folder in C:\server\cordova\phonegap-2.7.0\phonegap-2.7.0\lib\android\.

Also, if you do echo %PATH%, you should see the directories to your ant\bin, android-sdk\tools, android-sdk\platform0tools, and %JAVA_HOME%.

Upvotes: 1

vasanth
vasanth

Reputation: 715

is your Environment variables set for JAVA and ANT? Also, can you share the create command you are using? There should be no spaces in package names.

Upvotes: 1

Related Questions