得到错误,同时为phonegap添加android平台

时间:2014-10-02 13:07:24

标签: android cordova

今天我开始phonegap,根据文档,我正在尝试将我的环境设置到本地计算机中。

在此过程中,我安装了android SDK并在bashrc文件中设置了环境变量。

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME

ANDROID_HOME=$HOME/Git/adt-bundle-linux/sdk
export ANDROID_HOME
PATH=$PATH:$ANDROID_HOME

ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
export ANDROID_PLATFORM_TOOLS
PATH=$PATH:$ANDROID_PLATFORM_TOOLS

ANDROID_TOOLS=$ANDROID_HOME/tools
export ANDROID_TOOLS
PATH=$PATH:$ANDROID_TOOLS
export PATH

ANT_HOME=/usr/share/ant
export ANT_HOME
PATH=$PATH:$ANT_HOME/bin

我切换到我的工作总监,并在运行cordova platform add android

后收到以下错误
Creating android project...

/home/.cordova/lib/npm_cache/cordova-     
android/3.6.3/package/bin/node_modules/q/q.js:126
                throw e;
                      ^
Error: Failed to run "javac -version", make sure you have a Java JDK (not just a JRE) installed.
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:43:27
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Error: /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
@barrett:~/Git/phonegap/hellowPhonegap$

同样的命令与sudo cordova platform add android之类的“sudo”一起运行,引发了以下错误。

 /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
                throw e;
                      ^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
at _fulfilled (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
at flush (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Error: /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)

我稍后会使用哪个命令。如果其中之一,问题是什么。

任何人都可以帮助我。

4 个答案:

答案 0 :(得分:2)

我遇到同样的问题让我们这样做javac -version然后它显示可用的版本,如

The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-4.8-jdk
 * openjdk-7-jdk
 * gcj-4.6-jdk
 * openjdk-6-jdk
Try: sudo apt-get install <selected package>

休闲。 我希望这对你有所帮助。

答案 1 :(得分:0)

我有同样的问题 将此添加到您的路径中。在Windows中我确实喜欢这个path=%path%;%android_home%/platform-tools

答案 2 :(得分:0)

像这样添加路径到ANDROID_HOME

export ANDROID_HOME='your path'

检查echo $ANDROID_HOME

之类的路径后

答案 3 :(得分:0)

我发生的事情是,我安装了openjr e ,但javac实际上是openjd k 的一部分。希望这有助于某人。