Phonegap/Cordova build android node_modules/q/q.js throw e;
Solution 1
I noticed that your ANDROID_HOME variable might be incorrectly setup - as far as I can tell, it should be set to the root of your SDK folder (what you have ANDROID_SDK set to), try that (and make sure that you still have both $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools on your path).
Solution 2
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.
Solution 3
I run in the same problem and solved it by escaping non-letter characters in config.xml
. Particulary for the name
attribute:
<name>Temps d'espera</name>
I changed it to:
<name>Temps d\'espera</name>
And then it run perfectly. Hope it helps.
Solution 4
@mylord I had similar error and it was due to invalid debug certificate. On Linux Delete ~/.android debug.keystore file.
The next time you build, the build tools will regenerate a new keystore and debug key.
This solved for me. I hope this helps.
Solution 5
I ran into this same problem while running 'phonegap serve', but the solution was very different. I noticed that operation would work when I restarted my computer. In case anyone else runs into this problem. Here is the solution on Ubuntu 15
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
which was taken from the stackoverflow thread Grunt watch error - Waiting...Fatal error: watch ENOSPC
In addition to the posters error, I had the error
at exports._errnoException (util.js:856:11)
at FSWatcher.start (fs.js:1313:19)
at Object.fs.watch (fs.js:1341:11)
further down.
Related videos on Youtube
mylord
Updated on June 04, 2022Comments
-
mylord almost 2 years
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?
-
mylord over 9 yearsI did download Java 6 for OSX at Yosemite because Eclipse complained it needed it. I'll try to set my Java to that, but it's a strange error to get if that's the problem.
-
Marxama over 9 yearsYes, you're right, I had a similar error with the "q.js:126" error message, but turns out that's a very generic place for errors to occur (if I recall, it calls some external program, in this case ant I'd suppose). I may have found the solution in another question: Close Eclipse and run ant clean in your project folder. stackoverflow.com/questions/23753320/…
-
mylord over 9 yearsI moved that file and ran: cordova build android. Same error persists. Also, no other debug.keystore was generated. +1 for help anyhow. Any other ideas?
-
mylord over 9 yearsant clean gives: Buildfile: build.xml does not exist! The only build.xml I have in my project are related to the facebookconnect plugin. Any other ideas?
-
Marxama over 9 yearsRight, sorry - you'd need to go to (from your project root) platforms/android, the build.xml should be there. If it's not, or if you can't clean it, then you might want to try and re-create the project using Java 6 or 7. Also, I noticed that your ANDROID_HOME variable might be incorrectly setup - as far as I can tell, it should be set to the root of your SDK folder (what you have ANDROID_SDK set to), try that (and make sure that you still have both $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools on your path)
-
mylord over 9 yearsFixed by, as you said, changing to ANDROID_HOME=/Users/rover/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk fixed the problem for a new project. My other project with facebook plugin (and its own ant or something) still not working but that's another problem. Do you want to make an answer so I can set it as the solution?
-
Marxama over 9 yearsSure mate, I edited this one! As for it not having effect on your old project - not sure what the reason might be, but I've had similar problems where recreating a project from scratch resolved build issues.
-
mylord over 9 yearsThanks! Yes, I'm having trouble with my npm install as well. When I try to update cordova project, I get e.g. shelljs missing, and to install basically anything, npm is complaining of unmet dependencies etc... but that's another bug to hunt down :)
-
AnR over 9 yearsIf you could just re-install it should work I think. I have re-installed nodejs as well.
-
AnR over 9 yearsI have noticed one more thing also, after removing and adding Android platform. The output Apk file name apparently has also changed. Previously I used to get MyAppName-debug.apk. Now it is CordovaApp-debug.apk. This info would be helpful if you are using a DOS batch file to automate the process.
-
Wayferer about 9 yearsThis was my issue all along regardless of the build tools that I had installed.
-
Davut Gürbüz almost 9 yearsI'm having this issue.I have android platform for my project but have
build.gradle
instead of xml. Getting the same error. Any idea ? -
Davut Gürbüz almost 9 yearsI've ionic installed but command doesn't execute in my env. What should I need to add my path? Even though I have added all needed paths I get same error. This either didn't work for me. Cordova tutorial and ionic tutorial and these all answers didn't helped me much for this interesting
q.js:126
problem. Build doesn't work. But I can work with eclipse and test it on device or emu. -
Davut Gürbüz almost 9 yearsI've discovered the real cause after commenting the line and solved by this stackoverflow.com/a/16631694/413032
-
Davut Gürbüz almost 9 yearsI've discovered the real cause after commenting the line in q.js and solved by this stackoverflow.com/a/16631694/413032
-
Bishal Paudel over 8 yearsThank you very much. My solution is:
phonegap platform remove android
phonegap platform add android