Why does my phonegap build android command not work? - android

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

Related

Error : Unable to prepare project

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

Setting Android Home path in ionic framework

I want to run my ionic project in android device.So I ran following commands
Ionic add ionic-platform-web-client
ionic plugin add phonegap-plugin push
ionic io init
ionic platform add android
All the above commands were successfully executed.When I tried to run following command:
ionic run android
It gives me error:
'ANDROID_HOME' environment variable is set to non-existent path.
Try update it manually to point to valid SDK directory.
You may not have the required environment or OS to run this project.
How do i fix it now?
Try ionic build android before android run android
Just set you windows environment for the correct android home path

Installing PhoneGap Cordova 3.0

I was using phonegap 2.9 for development, it was pretty easy installing that but, phonegap 3.0 uses some nodejs and command line for installation. I found this tutorial but I am stuck at one step. untill this line,
npm install -g plugman.
it is working, but after this step there is a line,
Then change to the working directory to the project directory.
I can't figure this out and getting an error when i run
cordova -d platform add android
This is the error i am facing,
C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\util.js:57
throw new Error('Current working directory is not a Cordova-based
^
Error: Current working directory is not a Cordova-based project.
at Object.module.exports.cdProjectRoot (C:\Users\Comp\AppData\Roaming\npm\no
de_modules\cordova\src\util.js:57:19)
at CLI.platform (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\
platform.js:35:36)
at new CLI (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\cli.j
s:109:30)
at Object.<anonymous> (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordov
a\bin\cordova:41:16)
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)
Any help would be appreciated.
I think you haven't created a new project with:
cordova create [PATH] [ID] [NAME]
This will create a
.cordova, platform and www folder.
Things are a bit different when you use 3.3, you won't have a .cordova folder in that case but that doesn't really matter.
After running the create command you should add the android platform (after cd-ing into the path you entered with the cordova create command) with "cordova platform add android".
Now you should copy the contents of your 2.9 app www folder to the www folder Cordova created.
After running "cordova build android" you will notice that it copied the www folder to "platforms/android/assests/www", you should never change things here because running the cordova build android command will overwrite it.
More info on the following page: http://cordova.apache.org/docs/en/3.2.0/guide_platforms_android_upgrading.md.html#Upgrading%20Android

Cordova CLI on Windows8 can't find hooks

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\

Phonegap 3 doesn't work with Android Studio

It seems rather simple to me, but I can't do it at all.
I have npm install -g phonegap with everything successful and installing phonegap.
I have followed instructions from here http://phonegap.com/install/ i have then created my project:
C:\var\www\sexdiaries.co.uk>phonegap create sexdiaries -n SexDiaries -i co.uk.sexdiaries.app
I have then, as told Here tried to run andriod but with the following errors
C:\var\www\sexdiaries.co.uk\sexdiaries>phonegap run andriod
C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:72
self.phonegap.emit('log', 'detecting', platform.human, 'SDK environment...
^
TypeError: Cannot read property 'human' of undefined
at RunCommand.execute (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:72:52)
at RunCommand.run (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:55:10)
at PhoneGap.run (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\util\command.js:28:25)
at CLI.module.exports [as run] (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\cli\run.js:38:14)
at CLI.module.exports [as argv] (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\cli\argv.js:66:17)
at Object.<anonymous> (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js:24:21)
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)
More over, I have imported the project created into Andriod Studio, but when doing so I get: Source files for your project not found
I know how to create a working project using phonegap 2.9. But can't work out what 3 is offering?
So the question, how do I actually get a working local android app working using phoengap 3
The command is 'phonegap run android', It is not 'phonegap run andriod'.
Try it again. I had this problem like you.
I have used phonegap 3.0 with Android Studio and its working fine.
Please go through this
Upon must digging I found how to get past this:
phonegap run android
Its as simple as that.
[Edit]
You need to add platform to work with, whilst the documentation is so very very poor:
C:\var\www\sexdiaries.co.uk\sexdiaries>phonegap build android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[warning] missing library cordova/android/3.0.0
[phonegap] downloading https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.0.0;sf=tgz...
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
Then you are good to go, doing an import with Andriod Studio will also work now as you have a project to work with :)
Fantastic.

Categories

Resources