cordova - 安装 PhoneGap

标签 cordova

这是我尝试的第二天 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)

最佳答案

添加您的平台并首先构建它

npm install -g phonegap
phonegap create my-app
cd my-app
phonegap platform add android
phonegap platform build android
phonegap run android

也许在管理员模式下使用您的 cmd.exe。因为这个,我失去了很多时间..

关于cordova - 安装 PhoneGap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21939450/

相关文章:

JavaScript 循环未完成

ios - 如何防止 iphone 的 jquery 移动应用程序在 ipad 中自动拉伸(stretch)

android - 使用 url 的 facebook 私信

android - Eclipse android phonegap config.xml 不工作?

html - PhoneGap 数据库存储使用什么

android - 更改 html 文件但 apk 未在 cordova 中更新

android - Phonegap(在线构建)应用程序 - 没有互联网连接和网络状态

iOS状态栏重叠内容

ios - iOS 9 应用程序关闭时如何向服务器发出请求?

android - Ionic Serve 工作正常但运行 android 失败