ionic2:错误:找不到Android SDK。确保已安装。如果它不在默认位置,请设置ANDROID_HOME环境变量 [英] 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 variable

查看:1782
本文介绍了ionic2:错误:找不到Android SDK。确保已安装。如果它不在默认位置,请设置ANDROID_HOME环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This error has plagued me for a week now. I installed android studio, sdk and gradle and don't set variables in mac and Everything was working fine and I was running my ionic app in android devices and emulators until I got this error when I run on 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

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

I set the ANDROID_HOME and PATH variables in ~/.bash_profile which I created (the file wasn't exist in the system) but I still have the same error what should I do to solve this problem, and when I enter "android" in terminal I got that output:

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

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

what should I do to fix the problem?

推荐答案

我也用我的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 (注意目标不是目标)。也许这是旧版cordova中的拼写错误。

I also met this problem with my ionic-cli v3.9.2, and I found that the problem is reported by a file which is located in ${YOUR_PROJECT_DIR}/platforms/android/cordova/lib/check_reqs.js. The check_android_target method in this file use android list targets --compact command to check if you have installed android env correctly. But the correct command for this check is android list target --compact (notice target not targets) . Maybe it's a typo in old version cordova.

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

Ionic doesn't integrate the latest release of cordova. So my solution is fix this typo manually and it works.

更新:
当您解决第一个问题时,也许您会遇到另一个问题,即离子 - cli会告诉你,你没有安装模拟器,但你确实有一个。这是 $ {YOUR_PROJECT_DIR} platforms / android / cordova / lib / emulator.js 中的另一个错字。只需将安卓列表avds 更改为安卓列表avd 即可使其正常工作。

UPDATE: When you fix the first problem,maybe you will meet another problem that the ionic-cli will tell you that you don't have a emulator installed but you actually have one. It's another typo in ${YOUR_PROJECT_DIR}platforms/android/cordova/lib/emulator.js. just change android list avds to android list avd will make it work.

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

And then I found there's one more problems which causes the emulator can not be launched. May be this will help you.

这篇关于ionic2:错误:找不到Android SDK。确保已安装。如果它不在默认位置,请设置ANDROID_HOME环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆