Cordova Installation Guide

Cordova Installation Guide

1- Install Java JDK

You can download the latest version from Here

or if you have it installed on your device just run the following command in cmd to make sure it works
java -version

2- Install Node js

You can download the latest version from Here

or if you have it installed on your device just run the following tow commands in cmd to make sure it works
node -v
npm -v

3- Download Android SDK

You can download the latest version from Here

4- Download ant-server

You can download the latest version from Here

5- Add Variables to your path

Go to control panel then choose system then from the left side menu select Advanced settings

From Advanced tab selecte Environment variables

From the system variables part select new

in the variable name field type : ANDROID_HOME
then in variable value type the path where you downloaded Android SDK

add new variable for ANT_HOME and type the path where you downloaded Ant server
add new variable for JAVA_HOME and type the path where you installed JAVA wich is usual :
C:\Program Files\Java\jdk1.8.0_05
From the top part (User variables) add new variable with name PATH and value of :
%PATH%\tools;%ANT_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

now go to Node js command prompot and start installing cordova framework
npm install -g cordova
sudo npm install -g cordova //for linux and Mac OS X

when you finish you now have to install ionic framework
npm install -g ionic
sudo npm install -g ionic //for linux and Mac OS X

now you can GO ON and start new app
ionic start myApp blank
cd myApp
ionic serve //for testing on pc
cordova platform add android //to add android platform
cordova build android //to build an apk file
cordova run --device android // to run the app on your USB conntected device
cordova platform remove android //to remove platform

Common Errors

1- You Need SDK-Target 22

keep calm it’s not an error you just have a different android SDK version just remove platform and download older one

but first you need to now what is your current sdk target installed so run this command in Node js cmd
android list target
you will find the targets installed just pay attention to API level which in this case 19

you can solve this by changing the target version in your project setting

Go to your app folder -> platforms -> android -> open AndroidManifest.xml

change
target=android-22
to
target=android-19
then Go to your app folder -> platforms -> android -> open project.properities

change
android:targetSdkVersion="22"
to
android:targetSdkVersion="19"
2- invalid JAVA_HOME path
make sure the JAVA_HOME variable refer to you JDK version of java not JRE
C:\Program Files\Java\jdk1.8.0_05
3- Node.js command prompt not found
You can use normal cmd of windows instead of Node cmd but we have to add it to our environment variables first just like ANDROID_HOME


and fianlly we should add NODE_HOME to our path so go to user Variable and add NODE_HOME to it and make sure it look like this
%PATH%\tools;%ANT_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%NODE_HOME%;C:\Users\my user name\AppData\Roaming\npm
// change 'my user name' to your windows user name