Blog

Creating your first Phonegap (Cordova) application

Phonegap mobile development

Before starting, it’s worth knowing the difference between Cordova and Phonegap:

Apache Cordova is mobile application development framework. In 2011 Cordova was purchase by Adobe and rebranded to PhoneGap. The open source version of PhoneGap continues to be released as Apache Cordova. 

Apache enables software developers to build mobile applications using HTML5, JavaScript, and CSS instead of using platform specific APIs like Android, iOS, and Windows Phone. Although written with web technologies, Cordova applications have access to device hardware APIs like the camera, geo-location, and local file system. The result is a "Hybrid" app as the application's views are rendered through web-views, while still featuring access to device hardware APIs and being packaged and distributed in the same was as the fully native counterparts.

Phonegap Conveyor

Getting Started:

  1. Install Node.js
  2. Download and install the git client.
  3. Install cordova using the npm utility of Node.js (When using windows, the following commands will be inside the Node.js Command Prompt)

    npm install –g cordova

  4. Create a cordova application by first CDing into the folder where you projects will exist, then:

    cordova create hello com.example.hello HelloWorld

  5. The project has been created. Notice that the entire application exists under the “www” folder inside project. Remember that a cordova application is simple an HTML, CSS, and JavaScript application that gets exported to the native mobile platforms. Now it’s time to specify some target platforms for the application.

    Cordova platform add ios

    Cordova platform add android

  6. With the target platforms specified, the application can be built: Note: ensure that the Android
    SDK is and the Apple Xcode SDK is installed.

    Cordova build

    The application will be automatically built for both Android and iOS.

Working applications for both Android and iOS will be generated in the /platform/ directory of the cordova application directory. The resulting APK (for android) can be loaded onto a phone or emulated through the virtual device emulator.