Cordova在Ubuntu中添加平台错误

时间:2014-03-05 07:16:14

标签: android ubuntu cordova ant

我的Ubuntu 13.10 x64 Documents文件夹中有android最新的sdk工具.eclipse和sdk工作正常,还创建了一个虚拟设备。

cd Documents
cd adt-bundle-linux-x86_64-20130514/
cd sdk/
ls -l

它给了我这些,

add-ons
build-tools
docs
extras
platforms
platform-tools
samples
sources
system-images
temp
tools

现在使用ant

安装sudo apt-get install ant

然后编辑路径,

gedit ~/.bashrc

并在最后添加了此代码,

#AndroidDev PATH
export PATH=${PATH}:~/Documents/adt-bundle-linux-x86_64-20130514/sdk/tools
export PATH=${PATH}:~/Documents/adt-bundle-linux-x86_64-20130514/sdk/platform-tools 

现在,当我尝试将android平台添加到示例项目时,它会抛出错误,

cd hello
cordova platform add android

错误,

Creating android project...

/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at /home/######/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
    at /home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
    at /home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
    at flush (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)
Error: /home/######/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/lib/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)

1 个答案:

答案 0 :(得分:3)

我找到了同样问题的解决方案。我不知道究竟是什么解决方案,但我解决了它:

  1. 我从头开始重启。备份myproject.bak文件夹中的项目文件夹和

    启动phonegap创建myproject

  2. cd myproject

  3. cordova platform add android

  4. 我将项目资源从myproject.bak复制到我的新myproject

  5. grunt phonegap:build:android

  6. 此时我已经出错,因为我的项目中有重音文件。我用以下命令发现了这个错误:

    ant debug -f "/home/grattepoil/path/to/my/project/platforms/android/build.xml" -Dout.dir=ant-build -Dgen.absolute.dir=ant-gen -logfile log-ant.txt