You are here

Playtime with Cordova: pt.1 System setup on Ubuntu 13.10

Friday, July 18, 2014

DISCLAIMER: This is me sharing my days learning, I have not yet created a final application, and also, some of the process’ below may not be best practice.  BUT as a place to start playing, which is really what we all want to do, I think it works.

Good day reader, it's been a while since my last posting, so here come 5 all at the same time.  All of which are around learning how cordova SQLite and jQuery behave together.  It took me a little while to get all the pieces in the right places, and so this blog is for future Dan as much as it is for you (assuming there is anyone other than myself reading this).

To start with, we will get your environment setup.  Usually, all my web development is done within a nice vagrant box, with it’s own apache server, this prevents me from rinsing my whole machine when I want to try something new.  For this project though, a new process was required as there are various GUIs that just make things a LOT easier when playing with app development, as opposed to my usual website builds.

 

1. Install Node

As with pretty much anything in this new age of javascript frameworks, you will want to install node.  Cordova needs it, and to be honest, you want it too, even if just to play with things like Grunt (which would go quite nicely with a Cordova application I think).  The reason a new repository is added is because my version of Ubuntu (13.10) has an old version of node.js which fails later on in the process, so this gets you a nice shiny new version to gaze at.

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

 

2. Set node registry

You may also need to set the npm registry.  I did this on my first pass, but this may not be required due to the above newer version of node

npm config set registry http://registry.npmjs.org/

 

3. Install cordova

We then install cordova for all users (hence the -g for global) onto our machine

sudo npm install -g cordova

 

4. Download android sdk

Make sure you put this into a nice (and permanent) location on your system as you will be using it a lot in your new and future projects.  Get the files from http://developer.android.com/sdk/index.html I already had eclipse, so had to configure that seperately, but if you don’t yet have eclipse, why not just grab them both at the same time

 

5. Update the android SDK

The default download has a few old libraries in it, so just use your terminal to run the update

sudo tools/android update sdk --no-ui

 

6. Create a virtual device or two

Now we start creating some Virtual devices (AVD’s).  So take a look online at some device configurations, or just look at the requirements for the ones you want to test/support.

cd tools
sudo ./android
sudo tools/android avd

 

7. Add the paths to the PATH variable at the end of your .bashrc file

This path is used by all the applications to use android, this includes cordova when it tries to add a platform to your application.  You will need to copy the path to your own SDK files and replace mine below, but that is about it

sudo vim ~/.bashrc
PATH=${PATH}:/home/dan/working_files/android-sdk-linux/platform-tools:/home/dan/working_files/android-sdk-linux/tools
source ~/.bashrc

 

8. Install apache ant

We need this for cordova to work, so we might as well just install it now

 

9. Create your new project

Now, the time has come to wield your sword of cordovan power, decide on the application name which will forever be it’s title (well, until you change it that is), and go forth into the world.  For those adventurers that were wondering, the latter parts of the below command are in a reverse domain structure intentionally.  Therefore if I setup an app for my site it would have something like com.retrobadger.test

cordova create <foldername> com.<projectdomain>.<projectsubdomain> <projecttitle>

 

Useful resources:

Related: 

Blog & News

Monday, March 7, 2016

Okay, I know it is awful practice to put 2 things into one article, but I didn't want to write two tbh, so I will keep this tidy, and you can grab out what you need.

 

Subscribe to Blog & News

About

Cultivating a better future, with the seeds of better websites

For several years I have evolved through one of the largest media charities in the UK to the role of Senior developer.  I loved it there, but have to stepped out on my own as a freelance developer.

My main skills are with the Drupal CMS, developing code for it, ensuring standards through projects (whether that design, development, or planning), and leading teams to build applications they can be proud of.

Digital Consultancy, Web Development and Project Architecture are where I try to focus my skills, supporting my passion and desire to create stunning websites on time, in budget, and meeting your objectives.

To build a powerful web presence, I combine my creative, technical, and managerial experience (alongside a good splash of passion) which I have cultivated over 10 years in the industry, creating websites people want to shout about.

More on how I can help