I'm trying to compile my phonegap project using the cordova cli on my Win8 machine. I've updated all my Android SDKs, updated cordova and phonegap but I cannot build my project. I get an error that the .cordova/hooks/any_hook is empty.
I looked in that directory and can't see any files in there. How do those files get there and is the latest version of cordova bad? Until now I've been compiling on my Mac because I couldn't get the PC setup correctly so today I decided to take a crack at it and have failed.
I even created a new hello world project using the CLI but still no luck in building the thing because of the supposed missing hook files. Anyone have any insight to this.?
Also, I've tried using the command prompt in both ADMIN and regular mode. Still no luck.
EDIT:
I'm using phonegap 3.3.0-4.18.0
Path to hooks:
Z:\projecttitleroot\projecttitle.cordova\hooks
OUTPUT OF PHONEGAP BUILD WITH DEBUG:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build'
I want to point out that I'm using phonegap command to compile and run, NOT cordova as per the documentation for the latest version.
If I run:
cordova -d build android
I get this:
Z:\myprojectroot\myproject>cordova -d build android
C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build' at Object.fs.readdirSync (fs.js:654:18)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\src\hooker.js:64:34
at _fulfilled (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:760:13)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:821:14
at flush (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
Z:\myprojectroot\myproject>
Make sure you put your hooks into subdirectories inside the hooks directory.
Path to hooks: Z:\projecttitleroot\projecttitle.cordova\hooks\before_build\
Related
While trying to do a release using the following command:
code-push release-cordova myApp android
I'm getting the following error in the terminal:
Running "cordova prepare" command:
[Error] Unable to prepare project. Please ensure that this is a Cordova project and that platform "android" was added with "cordova platform add android"
Any one knows what might be wrong? The project is a cordova project created using the command:
cordova create myApp
And also has android platform added.
UPDATE :
Running cordova prepare android --verbose returns the following output :
Executing "before_prepare" hook for all plugins.
Searching PlatformJson files for differences between project vs. platform installed plugins
No differences found between project and android platform. Continuing...
Generating config.xml from defaults for platform "android"
Wrote out Android application name to "HelloCordova"
Wrote out Android package name to "io.cordova.hellocordova"
This app does not have launcher icons defined
updated project successfully
Executing "after_prepare" hook for all plugins.
Make sure your Nodejs is the last version.
code-push-cli required "child_process"
That error indicates that the current working directory didn't represent the root of a Cordova project at the time that you ran the release-cordova command. Can you make sure that you CD into the directory that contains the www, platforms, plugins, etc. directories, and then run the release-cordova command? That should do the trick for you
I'm new to cordova mobile app development. I have install Node and then install cordova. i have done those steps to create a cordova android app.
cordova create hello com.example.hellow HelloWorld This work fine
cd hello Navigation to directory_
cordova platform add android This is not working
This is the error showing my terminal
Jeys-MacBook-Pro:hello mactec$ cordova platform add android
Creating android project...
/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
at /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Jeys-MacBook-Pro:hello mactec$
Please help me to short-out this issue
Thanks in advance.
The problem is PATH wrongly defined on .bash_profile.
What i have done for this.
Change the path on bash profile open ~/.bash_profile. Then the bash profile open in a text editor.
Add the correct path to android SDK. If we have android studio then the path is /Application/Android Studio.app/sdk/ so we need to add this path to .bash_profile. export PATH=${PATH}:/Applications/Android\ Studio.app/sdk/tools
Then close all terminal and open again and code... :)
You can check that is working or not via typing android on terminal.
The error show in quite clear.You have to have the android sdk installed and proper path set in the system variable for the SDK, for cordova to work.See the prerequisites in cordova documentation http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html.For cordova 3.4 project android SDK must have target 19 installed.
Download SDK here http://developer.android.com/sdk/index.html
Here is the platform guide for more information http://cordova.apache.org/docs/en/3.0.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
If you already have the SDK installed,check to see if the path is refered properly for cordova to find
There's also another potential cause for this error: an errant file in your project/www directory. I had inadvertently included a blank file called project/www/:q ("colon q") in www/ (note I use Vim)! Anyway, doing this yields the exact error as noted by JeyTheva. So, delete that file and do the following:
cordova platform remove android
rm -r ~/.cordova/lib/android
cordova platform add android
Now rebuild and run on your device. This should work if you did something similar to what I did.
I have a phonegap created for iOS, and I want to build it for Android, but the following commands would not convert it to an Android project:
phonegap platform update android
phonegap install android
phonegap build android
Here is one of the errors that I receive:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap platform update android
[phonegap] updating Android platform...
[error] Platform "android" is not installed.
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap install android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[error] The provided path "/home/lucas/Dropbox/projects/ecostartup/ecometrix-app/platforms/android" is not an Android project.
Here is another error:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap build android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$
And here is some project info:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls
platforms plugins README.md www
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls platforms/
ios
How can I convert this to Android?
actually looking at your logs, it seems that the app has been built. The only visible error is that no phone was detected and the emulator could not be started.
About the commands you use :
phonegap platform update android this one is for when you already added android platform to your project and installed a newer version of phonegap so you don't need it for the moment
phonegap install android here you're trying to install your app to a device connected to your computer with proper drivers installed and debuging allowed
phonegap build android here you go, this is the good command to build the android project and generate a debug apk.
Once you run build, you should find the debug apk in platforms/android/bin
If you use some plugins, also check that they are compatible with android.
I double checked to make sure that Android was on my path:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app/platforms$ echo $PATH
(rest of path)...:/opt/android-sdk-linux/sdk/tools:/opt/android-sdk-linux/sdk/platform-tools
But I needed to install Cordova:
sudo npm install -g cordova
and I ran phonegap build android, which gave me another error to install Ant:
sudo apt-get install ant
This was all after installing nodejs, npm, and phonegap.
I found this post very helpful:
PhoneGap/Cordova Android Development
(it just took me a while to find it)
Whenever I try to build a project using phonegap run, I get the below error:
C:\Users\MS AwaN\my-app>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:87:29
at _rejected (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:808:24)
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:834:30
at Promise.when (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:752:41)
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:574:44
at flush (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
Can anyone please suggest what I am doing wrong?
I had the same problem and this fixed it. Alternately look here (which is the same but has a link to the documentation which I also missed).
It seems that phonegap 3.3 requires android sdk 19.
If you have a older one, try the following steps :
delete the platforms/android folder (as the log say "Adding the android platform", I assume you didn't perform any customisations in that folder)
use android sdk manager to install the latest sdk
retry with phonegap build android and if it fails, run phonegap -V build android to get more details on the error
i am new to phonegap 3 and android development.
i tried the command "phonegap build android" and get:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory 'C:\Users\Michael\.cordova\lib\android\
cordova\3.1.0\VERSION'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Object.exports.createProject (C:\Users\Michael\.cordova\lib\android\cordo
va\3.1.0\bin\lib\create.js:116:22)
at Object.<anonymous> (C:\Users\Michael\.cordova\lib\android\cordova\3.1.0\b
in\create:34:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
I simply add an empty file named as VERSION:
C:\Users\myuser\.cordova\lib\android\cordova\3.1.0\VERSION
after, I wrote this text inside it:
3.1.0
after, run phonegap again:
[phonegap] adding the Android platform...
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
Good luck!
It is kind of tricky This is the sequence I have to go through.
run a clean in eclipse (Project Menu)
sudo phonegap build android (cordova if that is what you are using)
then you have to reapply the read write permissions to the whole folder (this step may not be needed depending on your permissions)
then in eclipse run refresh on the project
then build.
Run
I would suggest as a bare minimum first step you should check via the command line that the following commands return a response that shows they are working correctly. They are all required. Ant - http://ant.apache.org/
Java -http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-sdk-6u3-jdk-7u1-downloads-523391.html
android - http://developer.android.com/sdk/index.html
In command line type the following to validate they work
Ant
java
android
Make sure you have node.js installed (http://nodejs.org/)
Also make sure you look at you PATH file and that everything is correct there.
As I say that's the basics (once you have stuff installed)
Try to install latest cordova. Maybe it will help:
$ sudo npm install -g cordova
(also you will need node.js installed)
I have removed android platform and added again.
cordova platform rm android
cordova platform add android
then,
cordova prepare android
is done without errors