Installing Cordova  on Linux

Installing Cordova on Linux

Cordova is a great free open source framework to build great mobile apps with the known web based technologies such like HTML5, CSS and JavaScript.

1- Installing Nodejs

You have to install NodeJs as Cordova is an node module can be found on npm registry as one of the most used npm projects.

To install it run the following from terminal

sudo apt-get install nodejs
we need also to install npm (Node Package Manager) via :
sudo apt-get install npm
In most cases the version installed is old one so we have to update it via the following commands:
sudo npm install n -g
sudo npm cache clean
sudo n stable
sudo npm update -g

Finally we need to check the versions to make sure we have the latest versions

node -v
npm -v

2- Installing Java JDK

for Android development we need to have JAVA JDK(JAVA Development Kit) to be able to build Android Apps.

To download and install it run :

sudo apt-get install java-8-openjdk
After downloading it we need to add it out environment path so we can use it from terminal to do this run:
sudo nano ~/.bashrc
and add the following to the end of the file
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin

make sure that “/usr/lib/jvm/java-8-openjdk-amd64” is the path where the Java JDK installed on your machine
then save and close it by press (ctrl+x) then (Y)

to make sure that everything is going fine check then version of the java installed
java -version

3- Installing Android SDK Manager

the other important thing to build android apps is to have Android SDK installed on your machine, so the next step is to download it from here Android SDK

unzip the file and put it in wherever you want then add its path to the environment just like we did with java
sudo nano ~/.bashrc
and add the following to the end of the file
export ANDROID_HOME=$HOME/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/platform-tools

check it by closing the terminal and open a new terminal then run :
it should open the sdk manager like the following
this sdk manager consists of three main parts (Tools, SDKs, Extras)
from tools check on the first three items (Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools)
then from the SDKs open the first one which is always the latest (may be Android 7.1.1(API 25))
and check on SDL Platform inside it, so we now have 4 packages ready to install (unchek any other option may checked by default) click on install 4 packages then accept the license and finally press install

Now we have all necessary tools to build and run Android Apps.

4- Install Cordova Framework

Now we are good to go with install Cordova framework itself by running :

sudo npm install cordova -g

and check that it installed by running :

cordova -v

5- Install Ionic Framework

Ionic is one of the most powerful UI frameworks for cross platforms mobile developments

Install it via :
sudo npm install ionic -g

and check that it installed by running :

ionic -v

6- Start Our First Ionic App

At this step our environment is ready to start the fun!

let’s create our first app and call it myApp

ionic start myApp --v1 blank
this should create a folder called “myApp” containing our base app.
cd myApp
now we have one last step which as building the app for Android devices
so we need first to till ionic we need to develop for Android:
ionic platform add android
then we can build an Android version from our app via:
ionic build android
this will take so much time for the first time because it will install one last thing need to develop Android apps which is “gradle” library
and once it get done we have gradle on our machine and can use it with any other machine.

when everything is done you should have message like this
build successful
and now you are ready to become a Cross-platform Mobile Apps Developer!