Apache Cordova development environment install on Ubuntu

Apache Cordova has very nice documentation, however as so many projects it focused on the Windows/MacOS duopolies only. Fortunately it’s not too hard to work out the differences.

Apache Cordova Logo

Installing dependencies

Thanks to: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

sudo apt-get install python-software-properties python g++ make ant

Installing Android SDK

Please note: one of the problems I found was that I had some Android tools from the Ubuntu repos that were conflicting with the SDK install. It’s probably a good idea to remove them first. That might save you from a lot of headaches down the line (and time to troubleshoot).

sudo apt-get remove android-tools-adb android-tools-fastboot

Download as per http://developer.android.com/sdk/index.html

wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz

Note: check for updated link version obviously

vim ~/.bashrc

Add the PATH variables to the top of the file

#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

Reload bash variables without reboot / logout

source ~/.bashrc

Testing SDK

android

This command should now bring up the SDK manager.

Installing Eclipse IDE

This is obviously an optional step depending on the IDE you want to use. I have previously covered a manual Eclipse install (as opposed to the Ubuntu repositories).

Install Eclipse ADT Plugin

As per: http://developer.android.com/sdk/installing/installing-adt.html

Node.js Install

The main difficulty on Ubuntu (as with so many development tools – see Eclipse above) is that the included node.js version in the Ubuntu repositories is outdated (remove the Ubuntu version with ‘sudo apt-get remove node’).

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

Install Cordova

sudo npm install -g cordova

Check Cordova Requirements

This will check for Android SDK installation, Ant and other dependencies – saving you going through error messages later.

~/.cordova/lib/android/cordova/3.4.0/bin/check_reqs

Create Cordova Project

mkdir ~/projects/PROJECTNAME
cd ~/projects/PROJECTNAME
cordova create ~/projects/PROJECTNAME com.COMPANYNAME.PROJECTNAME PROJECTNAME
cordova -d platform add android
cordova build

Create Eclipse Project

Open Eclipse
Create New Android project from existing sources
Import ~/projects/PROJECTNAME/platforms/android
Test in emulator by right clicking the project and selecting “Run As –> Android App”

Making VIM the default text editor on Ubuntu

In my never ending quest to find the ideal text editor here is another installment. Since I have been using VIM as my default command line editor for years I thought I give it a try for basic GUI editing as well.

VIM Logo

Install and set desktop app & icon

sudo apt-get install vim vim-gnome
sudo wget --output-document=/usr/share/applications/gvim.desktop https://raw.github.com/leogaggl/misc-scripts/master/gvim.desktop
sudo wget --output-document=/usr/share/icons/hicolor/scalable/apps/gvim.svg http://gfxmonk.net/images/vim-logo/vim-logo.svg
sudo update-desktop-database

Set MIME defaults

vim ~/.local/share/applications/mimeapps.list
#add or edit the following mime type and add others as needed
text/plain=gvim.desktop;

Ubuntu Apache2 – run VHOST as different user

There are several reasons why you might want to run different Apache Virtual Hosts as separate users from the Apache user account. My most frequent usage is on my development machine to allow running from my home directory.

The most commonly recommended option for this purpose is MPM-ITK (a quick hack would be to add yourself to the www-data group using “sudo usermod -a -G www-data USERNAME”)

sudo apt-get install apache2-mpm-itk
sudo a2enmod mpm_itk

Modify the virtual host config file in /etc/apache2/sites-available

<Virtualhost *:80>
ServerName HOSTNAME
ServerAdmin webmaster@domain.com
<ifmodule mpm_itk_module>
AssignUserID USERNAME GROUPNAME
</ifmodule>
DocumentRoot /home/USERNAME/www/docs
ErrorLog /home/USERNAME/www/logs/error.log
CustomLog /home/USERNAME/www/logs/access.log combined
</Virtualhost>

PLEASE NOTE:

If you doing this on a machine that already had a default install where MPM-PREFORK is enabled you have to disable

sudo a2dismod mpm_prefork
sudo a2enmod mpm_itk

Quick ‘manual’ Eclipse install on Ubuntu

Since I always had trouble with the Eclipse version that is avaialable via the Ubuntu repositories I often need to install Elcipse on new machinery. Hence I am documenting the process for myself and hopefully it might help others as well.

Orion’s Umbra by jah~, on Flickr
Creative Commons Attribution-Noncommercial 2.0 Generic License  by  jah~ 

If you haven’t got the Java dependencies

Java dependencies install

sudo apt-get install openjdk-7-jre openjdk-7-jdk icedtea-7-plugin

Eclipse download

Note: download link needs to be updated – current as of 2014-01-27

cd /tmp
wget http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/M4/eclipse-standard-luna-M4-linux-gtk-x86_64.tar.gz&mirror_id=1051
tar -xzf eclipse-standard-luna-M4-linux-gtk-x86_64.tar.gz
mv eclipse/ /opt
rm -f eclipse-standard-luna-M4-linux-gtk-x86_64.tar.gz

Create symlink

ln -s /opt/eclipse/eclipse /usr/bin/eclipse

Create application launcher

NOTE: (Edit 2014-01-27) as of Ubuntu 13.10 you need to change the ‘exec’ line in the desktop launcher to include “env UBUNTU_MENUPROXY=0″ as you otherwise will not see any of the menu items in the top nav-bar.

sudo touch /usr/share/applications/eclipse.desktop
echo "[Desktop Entry]" >> /usr/share/applications/eclipse.desktop
echo "Version=4.2" >> /usr/share/applications/eclipse.desktop
echo "Name=Eclipse" >> /usr/share/applications/eclipse.desktop
echo "Comment=Integrated Development Environment" >> /usr/share/applications/eclipse.desktop
echo "Exec=env UBUNTU_MENUPROXY=0 /opt/eclipse/eclipse" >> /usr/share/applications/eclipse.desktop
echo "Type=Application" >> /usr/share/applications/eclipse.desktop
echo "Icon=/opt/eclipse/icon.xpm" >> /usr/share/applications/eclipse.desktop
echo "Terminal=false" >> /usr/share/applications/eclipse.desktop
echo "NoDisplay=false" >> /usr/share/applications/eclipse.desktop
echo "Categories=Development;IDE" >> /usr/share/applications/eclipse.desktop
update-desktop-database

BESPIN – another nice one from Mozilla.org

Getting excited about a new text editor of all things is not something I like to admit to easily, but in my line of work (although less and less is actually doing hands on coding) text editing is an important part.

That’s why I checked out the BESPIN project as soon as I heard of it. The prospect of being able to edit your files from anywhere is very appealing to me since I spend a lot of time away from the desk and on devices that not always have good text editor (let alone all the files necessary). The thought of being able to edit files from a netbook while on the run is coming to mind straight away.

So far (even though this is a 0.1 ‘techo-preview’) I really like what you see. Not something that the average word processor crowd would find appealing or easy to use, but for somebody that is familiar with (specially *NIX) text editors it is easy to pick up and I can definitely see lots of potential there.

Bespin Dashboard

Bespin Dashboard

Editor Interface

Editor Interface

There are some important features still missing to make it truly useful in practical conditions, but I am sure they will be addressed in future revisions and it should be fairly easy to host your own since it’s basically Javascript & HTML5 and an Open Source project.

Great work by these guys:

Keep it coming ! Soon …