PhoneGap/Cordova
PhoneGap is a free and open source framework that allows you to create mobile apps using standardized web APIs for the platforms.
Before developing for any of the platforms, install cordova's command-line interface (CLI).
Prerequisites 1:
Before running any command-line, you need to install SDKs for each platform, to check whether SDKs are installed or not.
1. Open the command line (On the mac command line is available via "Terminal" application, On windows its available as "Command Prompt" under Accessories).
2. For the instance will check for android on MAC, In the terminal type "android"
$ android
3. If Android SDK is not installed in your system. Then download it from here
4. After that you need to Setup the PATH environment.
a. Setup the PATH environment variable on Mac OS:
- Open the Terminal program (this is in your Applications/Utilites folder by default).
- Run the following command
- touch ~/.bash_profile; open ~/.bash_profile
- This will open the file in the your default text editor.
- You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "/Development/android-sdk-macosx" as the directory the SDK is installed in.
- Add the following line:export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
- Save the file and quit the text editor.
- Execute your .bash_profile to update your PATH. source ~/.bash_profile
- Now everytime you open the Terminal program you PATH will included the Android SDK.
b. Setup the PATH environment variable on Windows:
- From the Desktop, right-click My Computer and click Properties.
- Click Advanced System Settings link in the left column.
- In the System Properties window click the Environment Variables button.
- Select the PATH variable from the System variables section.
- Select the Edit button.
- You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "C:\Development\android-sdk-windows" as the directory the SDK is installed in. Append the following text into the text box:
;C:\Development\android-sdk-windows\platform-tools;C:\Development\android-sdk- windows\tools
- Save your edit. Close the Environment Variables dialog.
- Additionally, you may need to include %JAVA_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type java. If the program can not be found add %JAVA_HOME%\bin to the PATH. You may need to specify the full path instead of using the %JAVA_HOME% environment variable.
- Finally, you may need to include %ANT_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type ant. If the program can not be found add %ANT_HOME%\bin to the PATH. You may need to specify the full path instead of using the %ANT_HOME% environment variable.
Prerequisites 2:
Now we are done with installing SDK and setting up the paths, now will move further. We will install Node.js before installing cordova/phonegap
You can install Node.js in different ways like Install Node with Homebrew or just download and install Node.js.
Following installation, you should be able to invoke node or npm on your command line.
Installation of Cordova :
Now at last we are here
1. Install the cordova utility. In Unix, prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
$ sudo npm install -g cordova
Create the App :
$ cordova create hello com.example.hello HelloWorld
It may take some time for the command to complete, so be patient. Run the cordova -d to see information about progress.
The first argument specifies a hello directory to be generated for your project. Its www subdirectory houses your application's home page, along with various resources under css, js, and img, which follow common web development file-naming conventions. The config.xml file contains important metadata needed to generate and distribute the application.
The other two arguments are optional: the com.example.hello argument provides your project with a reverse domain-style identifier, and the HelloWorld provides the application's display text. You can edit both of these values later in the config.xml file.
Add Platforms :
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Before you can build the project, you need to specify a set of target platforms. Your ability to run these commands depends on whether your machine supports each SDK, and whether you have already installed each SDK. Run any of these from a Mac:
$ cordova platform add ios
$ cordova platform add android
Build the App :
By default, the cordova create script generates a skeletal web-based application whose home page is the project's www/index.html file. Edit this application however you want, but any initialization should be specified as part of the deviceready event handler, referenced by default from www/js/index.js.
Run the following command to iteratively build the project:
$ cordova build
If everything goes good you will get the output
Generating config.xml from defaults for platform "android"
Preparing android project
Generating config.xml from defaults for platform "ios"
Preparing ios project
Compiling app on platform "android" via command "/Users/tekMunk/hello/platforms/android/cordova/build"
Compiling app on platform "ios" via command "/Users/tekMunk/hello/platforms/ios/cordova/build"
Platform "android" compiled successfully.
Platform "ios" compiled successfully.




















