2

I am unable to run ionic run android. After I checked with cordova requirements, it shows

Android target: Not installed
Android SDK not found.

enter image description here

How should I solve the problem? I have my SDK in D drive where I have set ANDROID_HOME and path correctly, I suppose enter image description hereenter image description here

Also, I do android list target, it shown as below. How should I intsall it if it is needed to fix teh error?enter image description here

Attached the cordova android version

enter image description here

  • what is your cordova-android version? – Suraj Rao Jul 04 '17 at 10:38
  • @suraj, please refer to the edited update –  Jul 04 '17 at 12:22
  • its very old https://stackoverflow.com/a/43677221/4826457 also https://stackoverflow.com/a/42805031/4826457 – Suraj Rao Jul 04 '17 at 12:27
  • @suraj, i am using windows 10, is it the same? May I know what is actually the cause of the error? My android version 5.1.1 is higher than my SDK? –  Jul 04 '17 at 12:31
  • windows or osx doesnt matter.. check the second link.. `android` command is deprecated and older cordova-android still uses that command which gives the error – Suraj Rao Jul 04 '17 at 12:38
  • @suraj is the solution is to run `cordova platform rm android; cordova platform add android@6.2.3`? The project in the directory is using android 5.1.1. My SDk is SDK android 4.1 which I intended to use. Is possible the project will be in android 4.1? –  Jul 04 '17 at 12:47
  • you will have to install older android command line tools..not sure where you would get that – Suraj Rao Jul 04 '17 at 12:49
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148320/discussion-between-behappy-and-suraj). –  Jul 04 '17 at 12:50

2 Answers2

6

You can follow this link set ANDROID_HOME which I got help from or follow below guide.

I had similar trouble but managed to fix it. After successful installation of android studio, Android SDK will be downloaded by default to a directory like this "C:\Users\abc\AppData\Local\Android\sdk1" where "abc" in this case is your PC name. AppData is a hidden folder.

Next step is to set ANDROID SDK path. From Advanced System Settings, click Environment Variables then under User variables add New as shown below.

enter image description here

Next, add android 'tools' and 'platform-tools' to System variables' 'Path' as shown below. These tools are inside sdk folder.

enter image description here

Set up is done. Open cmd and issue android command. If all is well, you should see below output. enter image description here

Finally open a new terminal window and navigate to your cordova project directory, in my case "hello" and check platfrom requirements. All should be fine now. enter image description here

Kim .J
  • 471
  • 5
  • 6
  • thanks! I'm on Mac, but your advice to add the tools to PATH solved the problem. I forgot that I modified my PATH in one terminal window, but forgot to source it in the window running the `cordova requirements` command – JP Lew Mar 02 '18 at 08:42
  • this did not fix my issue, but I rated for the quality of documentation – Naga Jul 23 '22 at 20:00
1

I had a similar problem. The issue was I was using the latest version of Java which was 10.0.1

You can check yourself by typing in terminal:

java --version

And it was

java 10.0.1 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

Currently, Cordova needs on their documentation page as JDK 8. SEE DOC HERE

You can download JDK 8 from the official website here

Once you download you need to set up JAVA_HOME variable. Use this for setting up JAVA HOME when you have multiple version of JAVA installed.

Then you can run

cordova requirements 

or

cordova build android

This worked for me. Hope it helps someone.

Pavan Mehta
  • 314
  • 2
  • 5