I have setup phonegap for android on my machine.I have searched over net and come with two different solutions for starting android project in phonegap
(1) Using Command Line Tool for creating project
phonegap create myFirstApp
cd myFirstApp
and then importing project in eclipse
(2) Directly from eclipse IDE
Choose New > Android Project and then filling necessary information
Now question is which should I use, and which one is better for starting phonegap project for android?
There is obviously, no single answer. You can use any, whatever you are interested in. Also, you can write your entire code in the www folder and may not open Eclipse at all.
Personally, I connect my android phone with USB debugging on, and whenever I feel like testing my app, I type in the command in the terminal
$ cordova run android
If you have configured a Virtual Machine, it will start the virtual machine or the app is installed directly on my device.
The correct way is
3) Using Command Line Tool for creating project
phonegap create myFirstApp
cd myFirstApp
Use any editor to edit the www folder (brackets, sublime)
Use the CLI to run, build, etc.
Forget about eclipse.
According to the Documentation the best way is as follows:
$ cordova create hello com.example.hello HelloWorld
$ cd hello
Then to add platforms:
$ cordova platform add ios
$ cordova platform add amazon-fireos
$ cordova platform add android
$ cordova platform add blackberry10
$ cordova platform add firefoxos
And run the app
$ cordova emulate ios
And build the app
$ cordova build ios
Related
i had build the ionic project (sample in 'www' folder) and run the sample in browser. but i need to convert the sample/project in to android app, and want to test that sample in my android phone. please provide what are all the software needed to do this and what are all the step by step procedure.
You will need the Android SDK to compile Android code. Set ANDROID_HOME environment variable to the SDK location.
On windows: set ANDROID_HOME=/path/to/sdk
From the command line, run the following command which generates an Android project:
ionic add platform android
Then build an apk file using this command:
ionic build android
Copy the apk to an Android device for testing.
The next step after starting an ionic project and building the app is deployment.
Make sure your device connected to your machine. Make sure android ionic support is enabled via $ionic platform add android. Check that android is supported via $ionic platform list.
Then build your app.
$ionic build android and run it $ionic run android
This should run to the connected device to test. You can also use emulators by adjusting the run syntax.
I have created the project with cordova CLI but i do not know where i need to change and how to run the cordova android project with eclipse for each platform. Thanks for helping
Before run the android project inside your Cordova Project you should know these things.
If you are making any changes in the Cordova Project then first you need to prepare the cordova. use the command cordova prepare
Then it changed in your config.xml (for android) automatic as you added or any changes you made. Do not make any change in your android project which exist inside your Cordova project. You can only make change inside the www folder of your Cordova project. And after made changed you need to make cordova prepare every time.
After prepare the cordova you can run the android project on device or emulator. For this you make sure you have made the path of android sdk for platforms-tools and tools in your environment system. If you not configure this path and add this two path in system environment .
Now run the android project on device use command cordova run android and run on emulator use this command cordova emulate android.
And if want to run on eclipse then you should import this android project of your workspace in eclipse. But if you again made changes in your cordova project then need to delete and again import the android project this switching happened every time so better to run through CLI.
I hope you got all things
Sunil's answer is good. I would like to add logging using Android Debug Bridge(adb).You may want to run:
adb logcat on a seperate shell window for logs after running cordova run android you need when you run into errors.This will produce huge logs, so I would recommend using:
adb logcat|grep Cordova
I have an issue with setting up an Android Project on Mac OS.
with the command:
$cordova platform add /path/to/androidSDK/android
I've got the error message:
[Error: Platform "/path/to/androidSDK/android" not recognized as core cordova platform.]
Does anyone have the same Issue ? How can I fix that ?
latest Android SDK version (downloaded today).
Phonegap version: 3.1.0-0.15.0
OSX 10.9 Mavericks
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
Hope this will help you.
this is documentation Phonegab docs
and my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
visit the solution here
I hope this helps you
I can't seem to figure out how to open up my android phonegap project in eclipse. I need todo this because I need to customize some android settings and files specifally to install facebook connect on phonegap 3.0.0. The app runs fine on my emulator, but the problem is that I can't find the local android files to open in eclipse. With ios its easy, you go into platforms/ios/projectname.xcodeproj and it opens your ios build in xcode. With android, it's nothing like this. I'm using this tutorial btw: https://github.com/phonegap/phonegap-facebook-plugin/tree/3.0
The Android Platform Guide has instructions on how you can use an IDE (eclipse) with Cordova 3.0.0 and the command line:
Use the command line to set up the new project:
$ cordova create hello com.example.hello "HelloWorld"
$ cd hello
$ cordova platform add android
$ cordova build
After that, open up Eclipse, select "New Project", hit "Android Project from Existing Code", and navigate to the hello/platforms/android folder that was created. This should load the project into your Eclipse workspace and you should be able to edit the Android files just like in the pre-3.0.0 days.
I installed nodejs and did the following:
npm install -g phonegap
phonegap create <app path>
cd <app path>
phonegap run android
when i execute the run android command, I get below error:
An error occurred during creation of android-sub project. The system cannot find the project specified.
not sure where this is coming from.
any clues.
Thanks
Had the same problems and a hard time finding a solution, however:
Make sure JAVA is installed
Set JAVA_HOME & PATH variables
Make sure ANT is installed
Set ANT_HOME & PATH variables
Make sure Android SDK is installed
Add PATH to sdk/tools
Add PATH to sdk/platform-tool
Run SDK manager to update & install SDK elements
Run AVD manager to create a default emulator image
Install NodeJS (with PATH)
Follow the usual tutorials
npm install -g cordova
cordova create hello com.sample.hello HelloWorld
cd hello
cordova platform add android
cordova build
now launch your Emulator
cordova emulate android (patience, take ages...)
or
cordova run android
much faster, just make sure you mobile device is connected, on, unlocked, usb debug is on, and drivers are installed
if you can't find one try: sdk\extras\google\usb_driver
npm install -g phonegap
phonegap create hello com.sample.hello HelloWorld
cd hello
phonegap platform add android (if not working use cordova command)
phonegap build android
now your launch Emulator
phonegap emulate android (patience, take ages...)
or
phonegap run android
much faster, just make sure you mobile device is connected, on, unlocked, usb debug is on, and drivers are installed
if you can't find one try: sdk\extras\google\usb_driver
I think the main difference between phonegap/cordova, is phonegap (which belong to Adobe) has the possibility to build in the cloud via https://build.phonegap.com/
Whitespace is not allowed i would say