Powered by Blogger.

APACHE CORDOVA INSTALLATION AND BUILDING APP


As the name suggests, Apache Cordova is a project maintained by the Apache foundation, the goal is to be an open-source framework for deploying applications developed in HTML / JS / CSS on several mobile platforms. ie, Its development is maintained by the Apache Foundation It is open-source, you can follow and contribute to its development.

The PhoneGap is a product maintained by Adobe, which aims to use the framework Apache Cordova, however, provide new resources for the developer. We can then define the PhoneGap is a distribution of Apache Cordova, with “something more”. Phonegap is built on Apache Cordova nothing else. You can think of Apache Cordova as the engine that powers PhoneGap. Over time, the PhoneGap distribution may contain additional tools and that's why they differ in command. But they do the same thing.

INSTALLATION

Step 1
Install Java development kit tools
$ sudo apt-get install openjdk-7-jdk openjdk-7-jre
Step 2
Now download and extract Android SDK bundle package (32 bit or 64 bit based on your OS) from
Step 3
Set PATH Variable for Android sdk (replace “/path/to/android/sdk” with the real path)
$ PATH=$PATH:/path/to/android/sdk
$ export PATH
To make the path setting permanent, write the path settings in bash. bashrc file.
$ sudo gedit /etc/bash.bashrc
Now type the following commands in the bottom of the file, save and exit
export path=$PATH:/path/to/tools
export path=$PATH:/path/to/platform-tools
or
gedit ~/.pam_environment
PATH DEFAULT=${PATH}:/path/to/tools
PATH DEFAULT=${PATH}:/path/to/platform-tools
Step 4
Now run Android
$ android
And install the selected API packages (android SDK tools, (android SDK platform-tools if not installed), android SDK build tools, android 4.4.2 (API 19)- SDK platform, ARM EABI v7a System Image, Intel x86 Atom System Image, Google APIs (ARM System image) , Extras – Android support library)
Step 5
Install nodejs and npm
$ sudo apt-get install nodejs npm
Step 6
Following installation, you should be able to invoke node or npm on your command line.
$ sudo npm install -g cordova

CREATE THE APP

Go to the directory where you maintain your source code, and run a command such as the following:
$ cordova create hello com.example.hello HelloWorld
The first argument specifies a hello directory to be generated for your project.
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.
Generated project may contain the following
hooks/
merges/
platforms/
plugins/
www/
config.xml
Replace files inside the www folder with your application source code which you wish to generate app

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
$ cordova platform add android

CHANGING THE APP ICON

platforms/android/res/
change icon.png in each folder

BUILD THE APP

$ cordova build android

You can find the apk files under platforms/android/ant-build dirctory
"HelloWorld-debugg.apk"

TEST THE APP ON AN EMULATOR OR DEVICE

1. emulator
    $ cordova emulate android
2. Alternately, you can plug the handset into your computer and test the app directly:
   $ cordova run android
3. Download apk and install the app
Move to the directory where test.debug.apk exists
  $ python -m SimpleHTTPServer 8000
browse ip:8000
download in android phone and install the app

No comments