10

I am trying to create a PhoneGap application using WebStorm 2016.3 IDE.

I am following this link link. I am able to create a project from the steps but while running the app I'm getting errors. While setting emulator I've found that Android SDK was not found.

I am unable to find how can I set that path here and the error I got is:

this

...and in log cat

"C:\Program Files (x86)\JetBrains\WebStorm 2016.3\bin\runnerw.exe" "C:\Users\Sa E\AppData\Roaming\npm\ionic.cmd" run --emulator android
✗ You cannot run iOS unless you are on Mac OSX.

I've tried some things by google but the data is for old IDE and I can't see such options with my current IDE.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Where is the android executable located? Seems it can't be found in your `$PATH`/`$ANDRIOD_PATH`. Can you check the `$PATH` value in WebStorm embedded terminal - try running `echo %PATH%` there? – lena Nov 28 '16 at 13:26
  • i dint get you but i am sure my sdk path was there in environment variables –  Nov 28 '16 at 13:49
  • what didn't you get? Where is your android executable located? Please make sure that it is in your %PATH% – lena Nov 28 '16 at 14:17
  • 1
    yes it is in my path but still iam unable to get it still i am getting x mark as shown in the image – Sa E Chowdary Dec 05 '16 at 12:27
  • In my case (Ubuntu) I had env variables defined in my .bashrc file. However I had to copy them to the .profile file. – Greg Dan Sep 06 '17 at 10:07

3 Answers3

9

I ran into the same issues on Windows. I added a system variable ANDROID_HOME with the address of the sdk folder. In my case it was
c:\Users\Andrew\AppData\Local\Android\sdk

After that, I restarted WebStorm, and it works fine.

PS make sure that you set up the project properly. Try creating a new project with type "PhoneGap/Cordova", then in the terminal type the following commands:

ionic start MyProjectName
ionic serve

If everything works at this point, then proceed:

ionic platform add android
ionic build android
ionic emulate android

You can use run instead of emulate if you have GenyMotion installed and running

Andrew
  • 2,309
  • 4
  • 27
  • 42
1

I used @Andrew's answer, but did not manage to make it work. It appears i needed more Environment variables; so, after many searches, I found this link on Cordova documentation which helped me in making PHPstorm recognize the Android SDK. The question was about Webstorm, but the Cordova plugin requires the same environment variables.

Here's a quote from that site (if you do not know how to set environment variables, follow the above link to get help):

Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:

  1. Set the JAVA_HOME environment variable to the location of your JDK installation

  2. Set the ANDROID_HOME environment variable to the location of your Android SDK installation

  3. It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH

Community
  • 1
  • 1
Erenor Paz
  • 3,061
  • 4
  • 37
  • 44
0

I faced the same problem with intellij idea ultimate on linux, while trying to run a cordova/phone gap project. Weirdly enough, the commands where running normally from the command prompt and the embedded terminal, however, trying to create a run configuration, I got the infamous errors. I have the environment variables set correctly, but, I have them set in ~/.bashrc which intellijidea seems not t read. I tried to add the variables manually in the same screenshot you included, with no success. The solution was to add ANDROID_HOME to the /etc/environment, rebooted, and everything worked as expected.

Mijo
  • 611
  • 8
  • 10