Thursday, February 20, 2014

Getting started with Apache Cordova using Fedora 20 for Android Development

Part 1: Setup Development Environment

1. Install required Software

  • Download and install Java SE SDK from Oracle (http://www.oracle.com/java) or use OpenJDK
    • Download the latest RPM. In my case it's jdk-7u51-linux-x64.rpm
    • Install it running
      sudo rpm -ihv jdk-7u51-linux-x64.rpm
    • Usually now you'll find your JDK here /usr/java/jdk1.7.0_51
    • There are also symbolic links pointing to the latest and default Java version
  • Install NodeJS and it's Package Mager npm:
    sudo yum install nodejs npm ant
  • Install Cordova:
    sudo npm install -g cordova
  • Download the Android Developer Tools Bundle for Linux from http://developer.android.com/sdk/index.html

2. Prepare your Development Environment

2.1. Setup Android Developer Tools

  • I've choosen ~/Development as my main directory for development purposes
  • Create a directory for ADT:
    mkdir ~/Development/adt
  • Move the ADT Bundle to your adt-Directory:
    mv ~/Downloads/adt-bundle-linux-x86_64-20131030.zip ~/Development/adt
  • Unzip the Bundle:
    cd ~/Development/adt
    unzip adt-bundle-linux-x86_64-20131030.zip

2.2. Set Oracle Java as your default Java Installation

  • Install Oracle Java as a new alternative:
    • sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/latest/bin/java" 2
    • sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/latest/bin/javac" 2
  • Set Oracle Java as the used one:
    • sudo update-alternatives --set "java" "/usr/java/latest/bin/java"
    • sudo update-alternatives --set "javac" "/usr/java/latest/bin/javac"

2.3. Prepare your environment

  • Open your ~/.bash_profile with your favourite text editor; i.e.
    vi ~/.bash_profile
  • Add the following lines at the very bottom of the file:
    JAVA_HOME=/usr/java/latest
    export JAVA_HOME
    JDK_HOME=/usr/java/latest
    export JDK_HOME
    PATH=$PATH:$JAVA_HOME/bin
    PATH=$PATH:~/Development/adt/adt-bundle-linux-x86_64-20131030/sdk/platform-tools
    export PATH
  • Run the following commando to apply your changed profile:
    . ~/bash_profile

3. Start Eclipse

  • Run the following command to start Eclipse:
    ~/Development/adt/adt-bundle-linux-x86_64-20131030/eclipse/eclipse
  • Now it's time to choose your workspace. In my case it's ~/Development/android-workspace
  • After you've choosen your workspace Eclipse should be ready to start with your first Android project

Part 2: A Apache Cordova HelloWorld Application

to be continued... tomorrow ;)

1 comment: