Hi!
I've decided to try out phonegap but i am having trouble getting it set up with eclipse using the CLI as the guides seem to be outdated and inaccurate. Here's what i've done so far to get the phonegap project set up in eclipse:
"phonegap create hello" to create a new phonegap project
then i tried "phonegap platform add android", but gave me a 'is not a node' error
from this question i got the idea that i should instead use "phonegap build android", so i used that command.
According to the android platform guide in the official phonegap website it says that now there should be a platforms/android subdirectory in the phonegap project folder, but there isn't. The platforms folder is completely empty.
Have i missed something? Thank you very much for your help :)
Please try phonegap install android.
By just typing phonegap without any arguments you'll get the basic help and when you want to know more of a specific command do phonegap help <subcommand>
Personally I found the Cordova CLI documentation to be a little more in depth and if you're just building locally you'll have no big difference between the cordova command and the phonegap command as far as I've been able to tell. You only really need the phonegap command if you're using PhoneGap Build as well.
Example:
% phonegap
Usage: /usr/local/share/npm/bin/phonegap [options] [commands]
Description:
PhoneGap command-line tool.
Commands:
create <path> create a phonegap project
build <platform> build a specific platform
install <platform> install a specific platform
run <platform> build and install a specific platform
local [command] development on local system
remote [command] development in cloud with phonegap/build
help [command] output usage information
version output version number
% phonegap help install
Usage: /usr/local/share/npm/bin/phonegap install [options] <platform>
Description:
Installs the application for a specific platform.
Automatically detects platform SDK support and uses the correct environment.
See each environment for available [options].
Examples:
$ /usr/local/share/npm/bin/phonegap install android
Related
I have just started with phonegap using below link.
http://docs.phonegap.com/getting-started/1-install-phonegap/desktop/
I have followed all steps and able to run my first phonegap app successfully.
I was really excited till now, but now I am stuck when i want to add plug-in(Speech Synthesis) to same app. doing some google, i found that, i need to install below things. Is there any other easy way for this?
Install Java (Set the path in environmental variables)
Download ADT Bundle and extract it and set the path in environmental variables.
Download and install Node.js from http://nodejs.org/ link. (Set the path in environmental variables if not set automatically)
Download Apache ANT.
Also step by step links for above steps are broken, please suggest the correct and easiest way to add plug-in to phonegap application.
I found it myself now..
below are the steps..
Install npm from https://nodejs.org/en/
Install phonegap CLI with below command
$ npm install -g phonegap
Instal GIT if not installed on your desktop fro their site or using below command.
npm install -g git
Add plugin using below command at the project directory
phonegap plugin add https://github.com/macdonst/SpeechRecognitionPlugin
phonegap plugin add https://github.com/apache/cordova-plugin-battery-status
Open your project again in Phonegap desktop app or use phonegap serve command to test it directly on mobile app.
No need of eclipse, ant, java....
I am trying to build a Cordova project on Windows using the steps I was given by the team who developed it.
Install Bower, Cordova CLI, Grunt CLI, SASS/Compass/sass-globbing gems
grunt build
cordova platforms add android
Then trying to run grunt emulate android but getting an error. I have the Android SDK installed and can fire up an emulator but I'm getting the following when trying to run that command:
Warning: Task "android" not found. Use --force to continue.
What am I doing wrong? I'm new to Cordova/PhoneGap development and all this interplay between packages is daunting.
You probably should run
cordova run android or grunt emulate:android
First part with cordova CLI should run all the time, and no need to use Grunt to launch application, if all assets are prepared.
Grunt part is just a guess work based on how I would organize Gruntfile.js and I could be wrong here. Without seeing more details, hard to tell you more.
Im new with phonegap, cordova and android. Im on mac, recently i install all the needs:
Phonegap 3.3.0-0.19.6
Cordova 3.3.1-0.4.1
Got Android SDK and running on eclipse with no problem. Then create a new Android application on eclipse for phonegap successfully, and running on a phone with android.
Then i create another app with cordoba(terminal), put 2 platforms android and ios, i run prepare etc.. and then import the project(android) into eclipse. At this point the app runs ok, so i proceed to install some plugins for testing (Notifications and Device)
https://cordova.apache.org/docs/en/3.0.0/cordova_device_device.md.html#Device
When i run the app with eclipse the examples always return
Uncaught TypeError: Cannot call method 'alert' of undefined
And its the same with device. So looking over the internet i found that if i run $cordova prepare will work, then i run the command, then run the app on eclipse and it work but always when i install a new plugin for testing i have to run cordova prepare, and the problem is that index.html rewrite with example hello world and i loose my code.
Any help over here, im doing ok?, how to install those plugins and make the test and dont have to run prepare all the time. (Please think on eclipse, i dont what to use terminal all the time)
I had the same exact problem and other posts suggestions didn't work for me.
I solved it by switching the steps a bit, despite the official docs and other posts.
If I add ALL the files AND the core plugins BEFORE I add the platforms, then adding the platforms takes these things with it into the new folder structures AND only build once from the command line before I open the project.
If I need to add anything I do it again. Although I can edit the www files without going through the process again, I do not expect the root www to perpetuate the platform www's. I just copy it myself into all the www folders. It shouldn't be this way but I think this is a well documented bug with multiple command line builds, for now and thats my working fix.
The recommended way is to edit html/js/css... in the root www folder of the project, not in the platfotms/xxx folders.
The reason is that if you have multiple platforms, you just need to modify in one place and cordova prepare or cordova build or phonegap build will propagate your code to all the platforms and update plugins.
If you have only android platform and want to be able to change code directly in eclipse for the platforms/android/assets/www folder, I suggest you create a shell script to
copy all the content of projectroot/platforms/android/assets/www to projectroot/www
run cordova prepare android
Then, instead of running cordova prepare android, you'll just have to run your script after you add new plugins.
Edit
I think there may be a better way for your problem.
You should be able to use plugman to install your plugins instead of cordova.
First you need to install plugman cli : npm install -g plugman
then install a plugin using
plugman -d --platform android --project projectname --plugin nameorurlofplugin
http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html
I had these issues too.
One approach I use now is:
Edit the index.html in the platform folders which is platform/iOS/appname/www and so. Then add plugins using the normal terminal way using cordova plugin add but always run the project using Xcode for iOS and eclipse and not from the terminal because then you will lose your code.
From my experience when you run using .xcodeproj or say android project the www on the inside is used and if you use cordova run ios from terminal the www on the outside will overwrite the www in the platform folders.
If you get xcode errors saying can't find so and so plugin files just move them to the path the error says xcode expects them to be in.
I just went to Phonegap and saw that I needed to install node.js to get started.
I did this, then followed the command line to install phonegap.
However, where is it? I don't see anything in my program files folder, I don't see Eclipse, and there's no documentation on what to do next on Phonegap's website. I don't understand why this instruction is so vague? What am I missing? And where did all those files I downloaded/installed go go?
Thanks
Phonegap 3.3 installation there is no proper info in phonegap site.
The reason of installing nodejs is, phonegap cordova are created as node modules.
Required Software’s:
Follow the steps. 1 Node Js 2 ANT 3 Android_sdk 4 JDK
open command prompt:
Follow the steps
C:\user\youruser>npm install -g phonegap
C:\user\youruser>npm install -g cordova
Set Environment variables:
Mycomputer -> Right Click -> properties -> Advance System settings -> Environment
variables
set path for 1. Java JDK 2. Android SDK 3. ANT
C:\user\youruser>cordova platform add android
C:\user\youruser>phonegap create First-app
C:\user\youruser>cd First-app
C:\user\youruser>phonegap run android
Phonegap will be installed and apk will be created in bin folder.
You will be getting
[phonegap] detecting Android SDK environment..
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] successfully installed onto device
You can able to see phonegap modules in C:\Users\yourusername\AppData\Roaming\npm.
Hope this will be very helpful. Let me know if you face any issues.
Phonegap installation steps present on the official site are somewhat vaguely presented and hasn't been properly updated.
With respect to your question, I think this post https://stackoverflow.com/a/18751002/4277415 might help you out.
Cheers.
Install phonegap without any error : http://www.markupjavascript.com/2014/07/installing-phonegap-in-windows.html
I am new to phonegap. I already have ADT in my PC.
1)I installed NodeJs.
2)I wrote on cmd
npm install -g phonegap
phonegap create my-app
cd my-app
phonegap run android
[phonegap]detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] No platforms added to this project. Please use 'cordova platform add <platform>'.
Here I already set the correct PATH. But the same problem occurring. If anyone knows plz let me know.
Thnx
Still not working .. Can anybody knows this .. Plz .. Thanks in advance..
I added these path for android: -
D:\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\platform-tools\
D:\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\tools\
and Java path is already set here.. So What's the problem here.. anyone can give the solution plz
EDIT: THIS ANSWER USES CORDOVA, NOT PHONEGAP
You must tell cordova which platforms you are going to use (e.g. android)
therefore, before executing command $cordova run android you must (once) execute cordova platform add android
For more details, see my answer here: Phonegap How to make android build
Regards, miweiss
At last I got the solution
Initially I wrote the command cordova platform add android, Then it was showing the error :
No platforms added to this project. Please use 'cordova platform add <platform>'.
I did some changes:
I change it to cordova -d platform add android
I reset all path, reset means again set my JAVA_HOME path and ANT_HOME path and then I gave the command cordova -d platform add android
then it was again showing error like There is no script engine for file extension .js. Then just use the command in commmand prompt assoc .js=JSFILE and put the command on prompt cordova -d platform add android and its done, now it contains android folder within platforms.
Thank You All for help
For Mac
just add the cordova path :
export PATH=$PATH:/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin:/usr/local/bin
now add platform like :
cordova platform add android
the platform will be added.