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

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

错误(截图)

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


当前回答

对于那些在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窗口几次或重新启动你的电脑后做出这些改变。希望这对你有用。

其他回答

Android path set in linux:

$export ANDROID_HOME=/usr/lib/android-sdk-linux
$export PATH=$PATH:$ANDROID_HOME/tools
$export PATH=$PATH:$ANDROID_HOME/platforms-tools

than

$cordova run android

Windows:

    set ANDROID_HOME=C:\ *installation location* \android-sdk
    
    set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

摘自本安装指南。

在Linux中,

编辑.bashrc文件,添加ANDROID_HOME和PATH变量,

export ANDROID_HOME=/usr/local/android-sdk-linux/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools

保存“。bashrc”文件后,运行

source ~/.bashrc

然后是字体

终端Android

如果它将运行,ANDROID_HOME和PATH设置,

如果你收到这条消息

bash: /src/android-sdk/tools/android: Permission denied

然后运行

sudo chmod a+x /usr/local/android-sdk-linux/tools/android

否则,您将得到相同的错误消息

Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

注意:使用您的android sdk安装路径,而不是/usr/local/android-sdk-linux/

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.

这就是你所需要做的。

我也遇到过同样的问题,我用这个找到了解决方案。

我做了以下步骤:

开放系统属性 环境变量 创建一个新的系统变量 名称:ANDROID_HOME 值:复制您的SDK路径(例如:我的SDK路径E:\SoftWares\Android-SDK)

关闭当前的cmd,并重新启动它 跑扑医生

这应该在Windows上工作