我试图安装PhoneGap,我得到以下错误:
错误:ANDROID_HOME没有设置,“android”命令不在你的路径中。你必须至少满足其中一个条件。
错误(截图)
我怎么做才能确保Android正确设置为使用Cordova?
我试图安装PhoneGap,我得到以下错误:
错误:ANDROID_HOME没有设置,“android”命令不在你的路径中。你必须至少满足其中一个条件。
错误(截图)
我怎么做才能确保Android正确设置为使用Cordova?
当前回答
这主要是丢失的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
其他回答
对于那些在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窗口几次或重新启动你的电脑后做出这些改变。希望这对你有用。
我有MAC OS X Yosemite, Android Studio 1.0.1, JDK 1.8和Cordova 4.1.2
当我尝试添加android项目时:
cordova platforms add android
我收到了这样的信息: ANDROID_HOME没有设置,“android”命令不在你的PATH中
根据cforcloud的回答… “错误:命令“android”失败”使用cordova 而且 http://developer.android.com/sdk/installing/index.html?pkg=studio 我使用了以下方法:
export ANDROID_HOME="/Users/<user_name>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<user_name>/Library/Android/sdk/tools/"
export ANDROID_PLATFORM_TOOLS="/Users/<user_name>/Library/Android/sdk/platform-tools/"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
echo $PATH
当我尝试创建android项目时,我收到了这条消息:
Creating android project...
/Users/lg/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:126
throw e;
^
Error: Please install Android target "android-19".
我运行Android SDK管理器,并安装了Android 4.4.2 (API 19)(除了Glass Development Kit Preview)。这对我很管用。
===
这是.bash_profile文件的内容。
export PATH=$PATH:/usr/local/bin
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
launchctl setenv STUDIO_JDK /library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
export ANDROID_HOME="/Users/<UserName>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<UserName>/Library/Android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/<UserName>/Library/Android/sdk/platform-tools"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
要使用终端编辑.bash_profile,我使用nano。这很容易理解。
cd
nano .bash_profile
我希望这能有所帮助。
如果其他方法都不起作用,请确保在构建过程中设置了正确的权限和所有权。快速解决方法可以是:
sudo chown -R <you>:<your_group> *
sudo chmod -R 755 *
对于Mac OS X:
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
你也可以在Visual Studio中设置ANDROID_HOME变量:
进入“工具->选项->跨平台-> c++”,进入“Android SDK”下的路径。