This document describes how to install Apache Cordova and the Android SDK on a Linux machine. Instructions below are tested on Ubuntu 14.04, on a 32-bit installation. For other versions and Linux distributions, the procedure may differ.
Please provide your feedback so that we can keep this documentation up to date. You are welcome to ask for help at the Evothings Forum.
Follow these steps to install Cordova:
Install Node.js. Node.js may already be installed. To test the installation, open a terminal window and type:
nodejs --version
If the version number is displayed, Node.js is installed.
If Node.js is not installed, install with:
sudo apt-get install nodejs
Also add the alias "node" for nodejs, as this is needed by Cordova:
sudo ln -s /usr/bin/nodejs /usr/bin/node
Install Node Package Manager (npm). Test if npm is installed by typing:
npm --version
If npm is not installed, install with:
sudo apt-get install npm
Install Git. Git is a version control system, which is used by Cordova behind-the-scenes. Test if Git is installed by typing:
git --version
If Git is not installed, install with:
sudo apt-get install git
Install Cordova. Cordova is installed using the Node Package Manager (npm). Type the following to install:
sudo npm install -g cordova
Test the Cordova install by typing:
cordova --version
If you see the version number, you have successfully installed Apache Cordova!
The Android SDK needs the Java Development Kit (JDK) to be installed (minimum version 1.6). Note that the Java Runtime Environment (JRE) is not sufficient, you will need the JDK. To check if you have the JDK installed already, type this in a terminal window:
java -version javac -version
If version info is displayed, you have Java installed, but you may want to use the Oracle JDK, rather than the OpenJDK that comes with many Linux distributions. The Oracle JDK is needed for signing Android apps.
If you wish to install the Oracle JDK, proceed as follows (the steps below are based on a guide from wikiHow):
Start by removing the OpenJDK:
sudo apt-get purge openjdk-\* sudo apt-get autoremove
Find out if you have a 32-bit och 64-bit Linux version:
file /sbin/init
If you run 64-bit Linux, you should install 32-bit libraries (Android SDK will need this):
sudo apt-get install ia32-libs
Download the JDK (Java SE Development Kit). The download file ends with .tar.gz. For 32-bit systems get the "Linux x86" download, for 64-bit systems get the "Linux x64" download.
The downloaded file is typically saved to the folder "Download" in your home directory. The following steps create an installation directory and unpack the JDK files there. You can pick any directory for the install, we will use the directory "java" in the home folder. Replace "jdk-8u11-linux-i586.tar.gz" with the name of the file you just downloaded.
mkdir -p ~/java cd ~/Downloads mv jdk-8u11-linux-i586.tar.gz ~/java cd ~/java tar xvzf jdk-8u11-linux-i586.tar.gz rm jdk-8u11-linux-i586.tar.gz
Check the name of the JDK install directory with:
ls
The path to the JDK becomes "~/java/jdk1.8.0_11" where "jdk1.8.0_11" is the name displayed by the ls command.
Add the path to the JDK by editing .bashrc in your home directory. You can use for example nano or gedit for this:
nano ~/.bashrc
or:
gedit ~/.bashrc
Add the following to the end of the file (replace "jdk1.8.0_11" with the actual folder name!):
JAVA_HOME=~/java/jdk1.8.0_11 PATH=$PATH:~/java/jdk1.8.0_11/bin export JAVA_HOME export PATH
Edit the .bash_profile file to load .bashrc. Opening a terminal windows runs .bash_profile, and we want our path settings to be available in the terminal. If not already present, add the following lines to .bash_profile (se nano or gedit as above):
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
Now you are ready to test the install. Close any open terminal windows, open a new terminal and type:
javac -version java -version
If version info is displayed you are done with the JDK install!
Apache Ant is a build system for Java, which is used by Cordova and the Android SDK. To install Ant, follow these steps:
Download Ant from here: ant.apache.org/bindownload.cgi. Get the zip download available at the page. Click the zip-file link for the most recent release, e.g. apache-ant-1.9.4-bin.zip, and save the file to your machine.
Unpack the zip file to the directory on your machine where you want Ant to be installed. You can pick any directory for the install, we will use the directory "ant" in the home folder. Here are the commands (make sure you use the actual name of the downloaded zip file):
mkdir -p ~/ant cd ~/ant unzip apache-ant-1.9.4-bin.zip rm apache-ant-1.9.4-bin.zip
To add Ant to the system path, edit .bashrc to contain the following lines at the end. Again, be careful to use the actual names of the files and folders on your system:
JAVA_HOME=~/java/jdk1.8.0_11 PATH=$PATH:~/java/jdk1.8.0_11/bin export JAVA_HOME ANT_HOME=~/ant/apache-ant-1.9.4 PATH=$PATH:~/ant/apache-ant-1.9.4/bin export ANT_HOME export PATH
Now test the install. Close the terminal window, open a new terminal (to make settings take effect) and type:
ant -versionIf you see a version number you have installed Ant successfully!
The SDK Tools for Android are used by Cordova to build Android apps. Follow these steps to install the SDK Tools:
Go to the page developer.android.com/sdk scroll down the page and click "VIEW ALL DOWNLOADS AND SIZES". Under "SDK Tools Only", click the windows installer file for Linux and download it (this file is named e.g. android-sdk_r23.0.2-linux.tgz).
When downloaded, unpack the files. Here are commands for unpacking the Android SDK folder into your home directory:
cd mv ~/Downloads/android-sdk_r23.0.2-linux.tgz . tar zxvf android-sdk_r23.0.2-linux.tgz rm android-sdk_r23.0.2-linux.tgz
The unpacked folder is named "android-sdk-linux" as of the release used in this example.
The Android SDK Tools need to be added to the system path. Edit .bashrc to contain the following lines at the end. Make sure you use the actual names of the files and folders on your system:
JAVA_HOME=~/java/jdk1.8.0_11 PATH=$PATH:~/java/jdk1.8.0_11/bin export JAVA_HOME ANT_HOME=~/ant/apache-ant-1.9.4 PATH=$PATH:~/ant/apache-ant-1.9.4/bin export ANT_HOME PATH=$PATH:~/android-sdk-linux/platform-tools PATH=$PATH:~/android-sdk-linux/tools export PATH
You need to have the specific Android SDK version used by Cordova. This is done by running the Android SDK Manager by typing the command:
android
This launches a window where you can select to install specific Android SDKs.
First time you launch the Android SDK Manager there will be preset selections. It is recommended to leave these untouched. Also select the entry "Android 4.4.2 (API 19)" is not installed already. This is the version used by the current Cordova 3.5 version. Note that the Android SDK required by Cordova will change in the future, as new versions of Cordova and Android are released. When this happens, open the Android SDK Manager again, and install the required API version(s).
To test the install, close the terminal window, open a new terminal and type:
adb versionThis should display version info for the Android Debug Bridge.
If you get stuck, consult the documentation at the respective web sites for Cordova, Java, Ant, and Android. The Cordova documentation has a platform guide for Android. You are also welcome to ask for help at the Evothings Forum.
One thing to do is to inspect all the environment variables. You can do this from a command window (note that you have to open a new command window after updating environment variables for updated values to be available). This displays the system PATH:
echo $PATH
Here is how to inspect the values of JAVA_HOME and ANT_HOME:
echo $JAVA_HOME echo $ANT_HOME
Next step is to create and build a Cordova project. Go to the Cordova Guide to learn more.
Evothings Studio makes it easy to develop Cordova apps. Check out how to use your Cordova project with the fast Evothings workflow.
It is easy and fun to get started with Evothings Studio. Download now and be up and running in 5 minutes!