Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap/Cordova build android node_modules/q/q.js throw e;

Tags:

cordova build android gives me the following err

node_modules/q/q.js:126 throw e; (*error details) 

This question has been asked before, but the typical answer regarding PATH and ANDROID_HOME hasn't worked for me.

I've put this into code snippet to avoid SO submission problems

export HOME="/Users/rover" export ANDROID_SDK="$HOME/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk" export ANDROID_HOME="$ANDROID_SDK/tools" export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$ANDROID_SDK/build-tools:$PATH" export ANT_HOME="/usr/local/bin/ant" #export PATH="$PATH:$ANT_HOME/bin" 

My environment variables:

$ set | grep "ANDROID\|PATH"

ANDROID_HOME=/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/tools ANDROID_PLATFORM_TOOLS=/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools ANDROID_SDK=/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk PATH=/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/build-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

$ which ant /usr/local/bin/ant $ ls /usr/local/bin/ant /usr/local/bin/ant  $ cordova --version 4.0.0  $ ant -v Apache Ant(TM) version 1.9.4 

I'm on Mac OSX 10.10 (Yosemite) which might have a problem with Java 8. Can this be related?

$ java -version java version "1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

$ ant --execdebug exec "/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/bin/java" -classpath "/usr/local/Cellar/ant/1.9.4/libexec/lib/ant-launcher.jar" -Dant.home="/usr/local/Cellar/ant/1.9.4/libexec" -Dant.library.dir="/usr/local/Cellar/ant/1.9.4/libexec/lib" org.apache.tools.ant.launch.Launcher -cp ""  (*error details)  BUILD FAILED /Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:653: The following error occurred while executing this line: /Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:698: null returned: 1  Total time: 1 second  /Library/WebServer/Documents/Booster/core_ionic_git/platforms/android/cordova/node_modules/q/q.js:126                     throw e;                           ^ Error code 1 for command: ant with args: debug,-f,/Library/WebServer/Documents/Booster/core_ionic_git/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen Error: /Library/WebServer/Documents/Booster/core_ionic_git/platforms/android/cordova/build: Command failed with exit code 8     at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)     at ChildProcess.emit (events.js:98:17)     at maybeClose (child_process.js:756:16)     at Process.ChildProcess._handle.onexit (child_process.js:823:5) 

Any ideas on fixing this?

like image 531
mylord Avatar asked Nov 06 '14 15:11

mylord


1 Answers

I banged my head against the wall for hours and hours and ultimately came up with a simple solution. I went into the project directory and issued two commands:

cordova platform remove android cordova platform add android 

Recompiled with "cordova build android" and it worked like a charm.

I think cordova wanted to possibly update some files.

===== Update for Ionic ========

In case you are using ionic framework then these are the commands for your rescue:

ionic platform remove android ionic platform add android 

I have noticed that this normally happens when you break (Ctrl-C) the compilation process.

like image 171
AnR Avatar answered Oct 17 '22 10:10

AnR