I have WebStorm and Android Studio installed. I have my Android SDK and Java environment variables set. I originally had this error (https://github.com/phonegap/phonegap-cli/issues/685) and I fixed that by extracting the templates folder as mentioned in that post.
When I run the PhoneGap demo project in WebStorm I now get:
BUILD SUCCESSFUL
Total time: 0.653 secs
Built the following apk(s):
/home/user/WebstormProjects/PageLoad/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/home/user/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Error: android: Command failed with exit code 2
So I then run phonegap run android --verbose
from the CLI and I got:
Built the following apk(s):
/home/user/WebstormProjects/PageLoad/platforms/android/build/outputs/apk/android-debug.apk
No scripts found for hook "before_deploy".
ANDROID_HOME=/home/user/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Running command: adb devices
Command finished with error code 0: adb devices
No target specified and no devices found, deploying to emulator
Running command: adb devices
Command finished with error code 0: adb devices
Running command: android list avds
Command finished with error code 2: android list,avds
Error: android: Command failed with exit code 2
at ChildProcess.whenDone (/home/user/WebstormProjects/PageLoad/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at maybeClose (internal/child_process.js:899:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
I also tried deleting my android-24
directory from $ANDROID_HOME/Sdk/platforms
and same result. That was actually the first thing I tried because rather than getting any error, running PhoneGap in WebStorm was just hanging.
PhoneGap CLI 6.4.5
node 4.5.0
npm 4.3.0
Android SDK Tools 25.3.1