这是我尝试install PhoneGap的第二天,所以请放轻松我。 这是我今天早上开始做的事情:
C:\Users\Phillip> npm install -g phonegap
C:\Users\Phillip> phonegap create my-app
C:\Users\Phillip> cd my-app
C:\Users\Phillip\my-app>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js
:87:29
at _rejected (C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_m
odules\q\q.js:808:24)
at C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.
js:834:30
at Promise.when (C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\nod
e_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\Phillip\.cordova\lib\android\co
rdova\3.3.0\bin\node_modules\q\q.js:752:41)
at C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.
js:574:44
at flush (C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_modul
es\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
编辑1:
C:\Users\Phillip\my-app>phonegap platform add android
[error] 'platform add android' is not a node C:\Users\Phillip\AppData\Roaming
\npm\node_modules\phonegap\bin\phonegap.js command. See 'node C:\Users\Phillip\A
ppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js help'
编辑2:
C:\Users\Phillip\my-app>%userprofile%\.cordova\lib\android\cordova\3.3.0\bin\che
ck_reqs.bat
[Error: An error occurred while listing Android targets]
编辑3:
C:\Users\Phillip\my-app>npm install -g cordova
编辑4:
C:\Users\Phillip>cordova create hello com.example.hello HelloWorld
Creating a new cordova project with name "HelloWorld" and id "com.example.hello"
at location "C:\Users\Phillip\hello"
Downloading cordova library for www...
Download complete
C:\Users\Phillip>cd hello
C:\Users\Phillip\hello>cordova platform add ios
Downloading cordova library for ios...
Download complete
Creating ios project...
'C:\Users\Phillip\.cordova\lib\ios\cordova\3.4.0\bin\create' is not recognized a
s an internal or external command,
operable program or batch file.
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Phillip\AppData\Roaming\npm\node_modules\
cordova\src\superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
答案 0 :(得分:9)
添加您的平台并首先构建它
npm install -g phonegap
phonegap create my-app
cd my-app
phonegap platform add android
phonegap platform build android
phonegap run android
也许在管理员模式下使用cmd.exe。我因此而失去了那么多时间..
答案 1 :(得分:2)
检查您是否具有the cordova platform guide
中列出的所有要求我最近发现了一个魔术命令,可帮助显示构建cordova android项目所缺少的内容:
%userprofile%\.cordova\lib\android\cordova\3.3.0\bin\check_reqs.bat
答案 2 :(得分:1)
我使用以下命令完成了此操作: -
$ sudo npm install -g phonegap
$ phonegap create my-app
$ 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/toolssource
上述路径应该是您的sdk工具路径。
$ phonegap run android after
现在上面的命令将在模拟器中运行你的应用程序。可能需要几分钟,所以请等待并查看结果。
此外,在使用CLI制作任何phonegap项目之前,您应该在系统中安装node.js.
答案 3 :(得分:1)
检查此博客是否可以帮助您正确安装并检查所遵循的所有步骤。 Installing cordova phonegap