我试图安装PhoneGap,我得到以下错误:

错误:ANDROID_HOME没有设置,“android”命令不在你的路径中。你必须至少满足其中一个条件。

错误(截图)

我怎么做才能确保Android正确设置为使用Cordova?


当前回答

如果其他方法都不起作用,请确保在构建过程中设置了正确的权限和所有权。快速解决方法可以是:

sudo chown -R <you>:<your_group> *
sudo chmod -R 755 *

其他回答

如果Linux用户仍然有同样的错误,可能他们已经使用了“sudo”添加android平台。这里有一个快速的解决方案,或者您已经使用sudo安装了cordova,这里也有一个解决这个问题的解决方案。

希望这对你有所帮助!

只需要一个改变就可以解决这个问题:

执行“开始->控制面板->系统->高级(tab) ->环境变量->系统变量”

设置ANDROID_HOME为C:\Program Files (x86)\Android\ android-sdk

在Linux上,将此添加到你的.bashrc, .profile或适当的shell文件的末尾:

export ANDROID_HOME=/home/youruser/whatever/adt-bundle-linux-x86_64-20140702/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools

请注意,这些环境变量将用于新创建的shell,而不是已经打开的shell。

对于Mac OS X:

export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

对于那些在windows上使用Ionic Framework并且在他们的pc上没有安装Android studio的人,你必须下载Android studio或在列表中下载SDK管理器。

如果你选择SDK管理器选项,你必须设置环境变量的路径:

Variable name: ANDROID_HOME, Variable value: the path where you installed the android SDK, in my case is, C:\Android\android-sdk. You have to add the variable to the Path variable system by adding this: ;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;. Then if you got the "JDK error" just download it from the Oracle website and create a system variable like the Android SDK: Variable name: JAVA_HOME, Variable value: the path where you installed the JDK, in my case is, C:\Program Files\Java\jdk1.8.0_144. Then add it to the Path variable system by adding ;%JAVA_HOME%\bin. Then if you got the "Gradle error" just fallow the installations steps on the official website of gradle. Finally you can continue to creating your ionic app's apk.

注意:你必须重新打开cmd窗口几次或重新启动你的电脑后做出这些改变。希望这对你有用。