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
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?
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
. Thecheck_android_target
method in this file useandroid list targets --compact
command to check if you have installed android env correctly. But the correct command for this check isandroid list target --compact
(noticetarget
nottargets
) . Maybe it's a typo in old version cordova.Ionic doesn't integrate the latest release of cordova. So my solution is fix this typo manually and it works.
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 changeandroid list avds
toandroid 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.