Cordova:未找到 Android SDK.确保它已安装.如果不在默认位置,请设置 ANDROID_HOME 环境变量 [英] Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable
问题描述
我在使用 Cordova 构建 android 时遇到问题,当我执行 cordova build android
时,我收到此错误:
I am having problem to build android with Cordova, when I execute cordova build android
, I receive this error:
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.
我已经这样做来修复它:
I have do this to fix it:
sudo nano ~/.bash_profile
并添加这一行:
export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools
然后这个:
source ~/.bash_profile
但是我在构建时再次出现该错误,我该如何解决?
but I get again that error when I build, how can I fix it?
更新:
这是我在 bash 中添加的行:
This is the line I Added in the bash:
export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools
export ANDROID_HOME=/Users/myname/Library/Android/sdk
推荐答案
最近的Android SDK 工具删除了 android
命令.
The recent Android SDK tools removed the android
command.
$ android -v
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
cordova
是更改的幕后推手,并且似乎有人在致力于此:https://issues.apache.org/jira/browse/CB-12554
cordova
is behind the change and someone seems to be working on it: https://issues.apache.org/jira/browse/CB-12554
您还可以将您的工具降级到 android
仍然可用的版本.
You can also downgrade your tools to a version where the android
was still available.
尽管如此,我还是找到了一种无需降级 SDK 工具即可运行 Android 应用程序的方法.我会 (1) 运行 cordova prepare
,然后 (2) 从 Android Studio 运行我需要的命令.就我而言,在模拟器上运行它就足够了.
Nevertheless, I found a way to run the Android app without having to downgrade my SDK tools. I would (1) run cordova prepare
, then (2) run the command I need from Android Studio. In my case, running it on the emulator was enough.
更新:问题 CB-12554 现已解决并发布cordova-android@6.2.0
版本.
UPDATE: The issue CB-12554 is resolved now and was released with the cordova-android@6.2.0
release.
更新:后续做了几个相关补丁,最新版本是cordova-android@6.2.3
.运行 cordova platform rm android;cordova 平台添加 android@6.2.3
来解决问题.
UPDATE: There were several related subsequent patches done and the newest version is cordova-android@6.2.3
. Run cordova platform rm android; cordova platform add android@6.2.3
to fix the issues.
这篇关于Cordova:未找到 Android SDK.确保它已安装.如果不在默认位置,请设置 ANDROID_HOME 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!