【问题标题】:ionic2: Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variableionic2:错误:未找到 Android SDK。确保它已安装。如果不在默认位置,请设置 ANDROID_HOME 环境变量
【发布时间】:2017-08-23 09:17:11
【问题描述】:

这个错误已经困扰了我一个星期了。我安装了 android studio、sdk 和 gradle,并且没有在 mac 中设置变量,一切正常,我在 android 设备和模拟器中运行我的 ionic 应用程序,直到在 android 上运行时出现此错误:

ERROR running one or more of the platforms: Android SDK not found. Make 
sure that it is installed. If it is not at the default location, set 
the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project

我在我创建的 ~/.bash_profile 中设置了 ANDROID_HOME 和 PATH 变量(该文件在系统中不存在)但我仍然有同样的错误我应该怎么做才能解决这个问题, 当我在终端中输入“android”时,我得到了输出:

The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.  

For command-line tools, use tools/bin/sdkmanager and 
tools/bin/avdmanager

*********************************************************************
Invalid or unsupported command "-version"

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk

我应该怎么做才能解决这个问题?

【问题讨论】:

    标签: android ionic-framework ionic2


    【解决方案1】:

    我的 ionic-cli v3.9.2 也遇到了这个问题,我发现这个问题是由位于 ${YOUR_PROJECT_DIR}/platforms/android/cordova/lib/check_reqs.js 的文件报告的。此文件中的check_android_target 方法使用android list targets --compact 命令检查您是否正确安装了android env。但是这个检查的正确命令是android list target --compact(注意target不是targets)。也许这是旧版本科尔多瓦的错字。

    Ionic 没有集成最新版本的 cordova。所以我的解决方案是手动修复这个错字,它可以工作。

    更新: 当你解决第一个问题时,也许你会遇到另一个问题,ionic-cli 会告诉你没有安装模拟器,但实际上你有一个。这是${YOUR_PROJECT_DIR}platforms/android/cordova/lib/emulator.js 中的另一个错字。只需将 android list avds 更改为 android list avd 即可。

    然后我发现还有一个问题导致模拟器无法启动。可能是this 会帮助你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多