9

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

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
xendi
  • 2,332
  • 5
  • 40
  • 64

1 Answers1

4

Android SDK tools 25.3.1 broke cordova-android and some other libraries.

Cordova Android 6.2.1 has been released after that and it's now compatible with Android SDK tools 25.3.1, but it's not compatible with Phonegap CLI 6.4.5 and cordova-android 6.2.1. You have to update to latest Phonegap CLI 6.5.0 first.

Then you can update your current incompatible android platform with cordova platform update android@6.2.1

Or you can remove the existing platform and add the new one (will delete any manual change you did inside yourProject/platforms/android/ folder)

cordova platform rm android

cordova platform add android@6.2.1

You have to specify the 6.2.1 version because current CLI installs cordova-android 6.1.x by default.

Also, don't update Android SDK tools to 26.x.x yet because it breaks cordova-android 6.2.1

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Now I get Error: TypeError: cordovaProject.projectConfig.getFileResources is not a function – xendi Apr 18 '17 at 09:49
  • then it might be a bug, not sure if it was tested on ubuntu – jcesarmobile Apr 18 '17 at 09:51
  • Crap, I was just searching on this last night, too. Talk about a timely solution. – Chris K Apr 18 '17 at 14:48
  • Please reference the new data here for a more complete answer and I'll go ahead and flag it: https://github.com/phonegap/phonegap-cli/issues/707 – xendi Apr 18 '17 at 20:48
  • @xendi thanks for the information, I've added the Phonegap CLI incompatibility information. Also, can you upvote this thread to make phonegap and cordova tags independent again? https://meta.stackoverflow.com/questions/337612/remove-phonegap-as-synonym-of-cordova-tag-and-make-it-independent-again As you can see, sometimes a Phonegap problem is not a Cordova problem and it will help having separate tags for them. – jcesarmobile Apr 18 '17 at 21:35