Saturday, November 3, 2012

Install Cordova-2.1.0(Previously a.k.a PhoneGap) on CentOS 6.3

  1. Download Cordova source code cordova-2.1.0-incubating-src.zip
  2. Extract the zip file and change into .../android/framework/ directory.
    Update ant property file by issuing  
  3. android update project -p . -t android-16
    ant jar
    
    If your ant version is less than 1.8.0, there'll be an error when compile the cordova like this
    BUILD FAILED
    /opt/android-sdks/tools/ant/build.xml:377:
    The Android Ant-based build system requires Ant 1.8.0 or later. 
    Current version is 1.7.1
    
    So it's better you have the Apache-ant >1.8 in hand before installing cordova > 2.0
  4. Install apache-ant. (The step is optional just in case you failed in step 2.)
    Download the latest version of ant from http://ant.apache.org/bindownload.cg
    Extract the installation file to where you usually install non-system apps and update the environment variables 'ANT_HOME' and 'PATH'in ~/.bashrc
    Add the following lines to your .bashrc file
    ## Apache-Ant ##
    export ANT_HOME=/opt/apache-ant-1.8.4/
    export PATH=$PATH:$ANT_HOME/bin
    
    You can check the basic installation with opening a new shell and typing ant. You should get a message like this
    Buildfile: build.xml does not exist!
    Build failed
    Caution:The cordova-2.1.0 is supposed to use against android-16 API, API <= 16 won't be compiled successfully!
  5. You should see cordova-2.1.0.jar in framework directory.
  6. Now you can create eclipse project with cordova supports
    Type in ./create <project_folder_path> <package_name> <project_name> in .../android/bin/ directory. If everything is OK, eclipse project will be created in the project_folder_path.