This blog aims at showing you how to build your first Cordova Mobile App, and deploy it on different native mobile platforms using command-line interface (CLI) to make it cross-platform. CLI is a great tool that allows you to create, run and debug a Cordova app on different mobile app development platforms.
Pre-requisite of Installing Cordova CLI
- Install SDK for Windows platform before installing CLI.
Steps to Install Cordova CLI for Windows:
- Download and install Node.js by following the link, http://nodejs.org/.
- Download and install a git client by following the link, http://git-scm.com/.
- Install Cordova module by using npm utility of Node.js..
- Give command for downloading Cordova :
Go to command prompt to run this command: C:\>npm install -g cordova
1. Set Environment Variable path for Android SDK Cordova App Development.
Copy the path till tools folder of Android SDK & paste it on Environment Variable Path section separated by semicolon from existing path. e.g: D:\latest SDK\adt-bundle-windows- x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\tools.
To get Android-SDK path follow these steps:
i) Open Eclipse, which is configured with Android SDK.
ii) Go in window> Preferences > Android > SDK Location
iii) Copy the SDK location full path to find the folder of tools.
Create the App:
1. Go to command line and navigate your drive’s folder where you need to create the Project.
2. Run Command : D:\AndroidApp> cordova create com.example.hellocordova MyApp
This command will create a project with the name MyApp with package name, com.example.hellocordova in “D” Drive, AndroidApp folder.
3. Run command to jump in App Folder by calling: cd AndroidApp.
This command will take you to the Actual Cordova App Folder.
4. Run command: D:\AndroidApp> cordova platform add android
This includes creating/adding project for Android platform with all the required Android root folders like src, res, asset etc.
5. Run Command: cordova build
This command is used to build the project before running. Note the same step must be repeated if you are making any change on MyApp (Created Cordova app to reflect changes).
Now Cordova Android App is ready. Go to the AndroidApp folder and import this project in Eclipse IDE as Android Existing Project like:
Go in Eclipse IDE: File> Import > Existing Android Code into WorkSpace
After Importing the Project as Android Project, you can now run it on Device/Emulator as Android App.
Posted by-
Atul Yadav
Disclaimer: Developer’s Corner Section of ISHIR blog is contributed and maintained by independent developers. The content herein is not necessarily validated by ISHIR.