phonegap无法安装或正常工作

时间:2014-08-17 05:20:04

标签: android eclipse node.js cordova npm

安装NodeJ并运行npm install -g phonegap之后,我得到的格式与应有的格式完全不同:

C:\Program Files\nodejs>npm install -g phonegap
|


> ws@0.4.31 install C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules
\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\engi
ne.io\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

/
C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules\phonegap\node_modul
es\connect-phonegap\node_modules\socket.io\node_modules\engine.io\node_modules\w
s>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild
-


> ws@0.4.31 install C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules
\phonegap\node_modules\connect-phonegap\node_modules\socket.io\node_modules\sock
et.io-client\node_modules\engine.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

-
C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modules\phonegap\node_modul
es\connect-phonegap\node_modules\socket.io\node_modules\socket.io-client\node_mo
dules\engine.io-client\node_modules\ws>node "C:\Program Files\nodejs\node_module
s\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\Users\kyle David Krueger\AppData\Roaming\npm\phonegap -> C:\Users\kyle David
Krueger\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js
phonegap@3.5.0-0.21.14 C:\Users\kyle David Krueger\AppData\Roaming\npm\node_modu
les\phonegap
├── pluralize@0.0.4
├── semver@1.1.0
├── colors@0.6.0-1
├── minimist@0.1.0
├── qrcode-terminal@0.9.4
├── shelljs@0.1.4
├── cordova@3.5.0-0.2.7 (q@0.9.7, underscore@1.4.4, nopt@2.2.1)
├── prompt@0.2.11 (revalidator@0.1.8, pkginfo@0.3.0, read@1.0.5, utile@0.2.1, wi
nston@0.6.2)
├── phonegap-build@0.8.4 (qrcode-terminal@0.8.0, shelljs@0.0.9, optimist@0.3.7,
phonegap-build-api@0.3.3)
├── connect-phonegap@0.12.8 (home-dir@0.1.2, connect-inject@0.3.2, shelljs@0.2.6
, request-progress@0.3.1, useragent@2.0.8, gaze@0.4.3, node-static@0.7.0, tar@0.
1.19, request@2.33.0, localtunnel@1.3.0, socket.io@1.0.6, connect@2.12.0)
└── cordova-lib@0.21.7 (osenv@0.0.3, properties-parser@0.2.3, mime@1.2.11, bplis
t-parser@0.0.5, q@0.9.7, semver@2.0.11, underscore@1.4.4, dep-graph@1.1.0, plist
-with-patches@0.5.1, npmconf@0.1.16, rc@0.3.0, xcode@0.6.6, elementtree@0.1.5, g
lob@3.2.11, tar@0.1.19, request@2.22.0, cordova-js@3.6.2, npm@1.3.4)

然而,这似乎可行,因为我可以创建新的phonegap项目,但也有错误:

C:\Users\kyle David Krueger\workspace>phonegap create aoeu com.kdk.aoeu aoeu
[phonegap] missing library com.kdk.aoeu/www/3.5.0
[phonegap] downloading https://github.com/phonegap/phonegap-app-hello-world/arch
ive/3.5.0.tar.gz...
[phonegap] create called with the options C:\Users\kyle David Krueger\workspace\
aoeu com.kdk.aoeu aoeu
[phonegap] Customizing default config.xml file
[phonegap] created project at C:\Users\kyle David Krueger\workspace\aoeu

然后尝试运行phonegap运行android导致类似的情况似乎工作,但有错误

C:\Users\kyle David Krueger\workspace\aoeu>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...

C:\Users\kyle David Krueger\.cordova\lib\android\cordova\3.5.1\bin\node_modules\
q\q.js:126
                    throw e;
                          ^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
    at C:\Users\kyle David Krueger\.cordova\lib\android\cordova\3.5.1\bin\lib\ch
eck_reqs.js:47:27
    at ChildProcess.exithandler (child_process.js:652:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Socket.<anonymous> (child_process.js:969:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)
{ [Error: cmd: Command failed with exit code 8] code: 8 }
   [error] cmd: Command failed with exit code 8

最后,打开Eclipse并尝试创建一个新项目会出现错误“parseSdkContent failed”。这实际上在您选择要导入的文件之前出现,并且在从头开始创建全新的Android应用程序时也会出现。 看起来这可能都是由多个错误引起的,或者都可能是由一个错误引起的。

1 个答案:

答案 0 :(得分:1)

您需要从http://ant.apache.org/bindownload.cgi

手动下载ant

然后在某处提取它。假设在驱动器D:\apache-ant-1.9.3

接下来添加环境变量ANT_HOME及其值D:\apache-ant-1.9.3

最后将其添加到路径变量%ANT_HOME%\bin

不要忘记重启终端或命令提示符