/ programming

Setting up with Cordova under Linux

Building mobile apps with HTML/CSS may not be universally beneficial but for certain types of apps it does offer the write-once/deploy-everywhere attitude that Xamarin valiantly fails at.

The Apache Cordova platform (currenty at version 4) is the enabler here and its magic allows developers to leverage their knowledge of a variety of frameworks to get the job done: Sencha Touch, jQuery and/or jQuery Mobile, AngularJS/Bootstrap or AngularJS/Yeoman or even better: Ionic Framework (here's a quick start guide).

To leverage Sencha Touch, use this tutorial. Although it mentions Sencha Touch 2.3 and Cordova 3, I've got it up and running with Sencha Touch 2.4.1 and Cordova 4.1.2 in the same way, the only additional requirement is the installation of Ruby

sudo apt-get install ruby

The modern Cordova requires the following:

  • nodejs (I recommend building node from source rather than getting the binary from distro repository or downloaded binary)
  • npm (comes with node)
  • ant (if you install via package manager, it will pull Java in for you as well)
  • Android SDK (on Linux you can't build apps for iOS or WP8, to work around that you could use a machine in VirtualBox)

To install cordova:

sudo npm install -g cordova

To ensure all this are available, set these environment variables (best set in ~/.bash_profile to be run at login):

export ANDROID_HOME=/path/to/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME:$ANDROID_HOME/platform-tools

Once all is set, run:


and install all needed platforms (Cordova requires API level 19 by default)

Some basics:

cordova create myapp com.mypackage.myapp MyAppTitle
cordova create <folder to create> <package path to use> <app title for display>

cd myapp

cordova platform add android
cordova platform add <platform name = android/ios/wp8/etc>

cordova build

(run from inside the myapp folder, it also takes a specific platform name as additional parameter)

cordova emulate <platform>

(rebuilds and launches the app in an emulator)

Setting up with Cordova under Linux
Share this