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

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

错误(截图)

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


当前回答

你也可以在Visual Studio中设置ANDROID_HOME变量:

进入“工具->选项->跨平台-> c++”,进入“Android SDK”下的路径。

其他回答

这主要是丢失的andriod SDK。对于这个问题和“JAVA_HOME”错误跟踪解决方案为我工作…按照以下步骤节省了一整天。

要构建和运行应用程序,您需要为每个目标平台安装sdk。或者,如果你使用浏览器进行开发,你可以使用不需要任何平台sdk的浏览器平台。

检查您是否满足搭建平台的要求:

$ cordova requirements
Requirements check results for android:
Java JDK: installed .
Android SDK: installed
Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:23
Gradle: installed

Requirements check results for ios:
Apple OS X: not installed
Cordova tooling for iOS requires Apple OS X
Error: Some of requirements check failed

在Mac上使用Android Studio,在你的终端上运行这个:

export ANDROID_HOME=/Applications/Android\ Studio.app/sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools

然后,当你打字的时候

android

在您的终端上,它将运行一些内容

在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。

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

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

Go to system properties. Click change setting. Click advance tab. Click Environment Variables button. In system variables area click new button. Set ANDROID_HOME in the Variable name field. Set C:\Program Files (x86)\Android\android-sdk in the Variable value field. Click ok button. Double click Path variable in the list. Click new button. Past C:\Program Files (x86)\Android\android-sdk\platform-tools in the filed. Click new button again. Past C:\Program Files (x86)\Android\android-sdk\tools in the field. Press enter 3 times.

这就是你所需要做的。