cordova构建android在Ubuntu 12.04上引发错误

时间:2015-04-05 19:04:14

标签: android cordova

这个问题看起来非常熟悉 Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.

但我无法修复它。我跑的时候

% sudo cordova build android  

我收到以下错误

Running command:   /home/thabung/mobile/hello/platforms/android/cordova/build 
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
  at ChildProcess.emit (events.js:98:17)
  at maybeClose (child_process.js:766:16)
  at Process.ChildProcess._handle.onexit (child_process.js:833:5)

我观察的几件事

 % echo $ANDROID_HOME

给我回报

 ~/mobile/android-sdk-linux

这是完美的位置 &安培; android命令也可以正常工作。 请帮忙.. 我正在使用cordova 4.3.0

1 个答案:

答案 0 :(得分:2)

这......

sudo cordova build android  

root 的环境中运行,而这......

echo $ANDROID_HOME

未作为 root 执行。检查echo $ANDROID_HOME返回 root 的内容 - 或(强烈推荐) - 将Cordova作为 root 以外的其他用户运行。

p.s。 :我在没有sudo的Ubuntu 14.04上运行Cordova 4.0.0。