Cordova is an Apache project which allows you to develop mobile apps in HTML - so if you are competent with html and javascript, its quite a straight forward process to create apps. I've just bought a new MacBook which I need to set up with Cordova, so I thought I would document the steps as I go along. As you would expect with an Apache project, theres a ton of documentation available at https://cordova.apache.org/
I'm assuming that the reader is familiar with basic Unix operations, and use of the sudo command.
** Update - once you have read this, see Cordova - my first App **
Install Android SDK
The first step before starting with the Cordova install is to install the relevant SDKs for the mobile app type you are going to develop - Im only interested in Android, so I need to install the Android SDK
- Go to Download Android Studio and SDK Tools | Android Developers and download Android Studio. An alternative is just do download the SDK but Im getting the complete studio in case I want to do any 'native' Android development later
Downloading and installing the SDK on Mac is very straightforward - and is fully explained at the above link - its just downloading the .dmg image, opening and dragging to the Applications folder.
Once you have done this you need to open Android Studio and run through the wizards which pop up, in order to complete the installation.
Having now installed the SDK, it needs to be configured in order to meet the requirements of Cordova. Attempting to build a Cordova project without following the next steps will result in the following fault
To change the configuration open the SDK Manager withe the following command
/Users/[username]/Library/Android/sdk/tools/android.
(If this doesnt work - i.e. this location is invalid, skip this step and continue with the steps below - then when you try and build your first project it will throw the error above which contains exact details of how to open the SDK manager !!)
When the SDK Manager is opened you need to make sure that Android API version 22 is installed (Android 5.1.1). I found that the default was Android 6 (API version 23) which is not compatible with Cordova. What I did was to uninstall Android 6 and instal Android 5.1.1).
It may well be that when you start trying to build Cordova projects you have to keep coming back to this point to tweak the configuration to match Cordova's requirements. The good news is that the Cordova build process seems to be quite good at giving meaningful error messages indicating what exactly is wrong with the Android setup.
Install Java SDK
- Java SDK need to be installed - I had already done that - for more instructions go to Java SE - Downloads | Oracle Technology Network | Oracle (I installed Java 8 SDK).
Cordova Command Line Interface (CLI)
I intend to run Cordova from the command line so I followed the instructions at https://cordova.apache.org/docs/en/4.0.0/guide/cli/ as follows;
Install Node.js
Cordova uses Node JS commands in its CLI - therefore you need to install Node.js!
Go to https://nodejs.org/en/ and follow in e instructions there. On Mac the download opens its own installer which runs and finishes with the following prompt. Note the requirement to Make sure that /usr/local/bin is in your $PATH - this can be checked by typing echo"$PATH" in a terminal session.
Install Git client
Even if you are not using Git for source control, Cordova uses it behind the scene to download assets, so you will need to install a Got client. To check if you already have it installed type git at a command line - if its there you should see something like this. If not, go to Git and follow the instructions there.
Download Cordova
Now Git client is installed, we can use the npm command to download Cordova. Type the following command into a terminal session
sudo npm install
This will download Cordova and install into location /usr/local/lib/node_modules/cordova/
I've written a follow up blog at Cordova - my first App which details writing my first app.
Top Comments