How to setup and build cordova application for Android
Date : 22/08/2019
In cordova, there are certain plugins are used to to communicate with os and HTML/CSS. In the following tutorial we will see how to create cordova application.
Installing the Cordova CLI
The Cordova command-line tool is distributed as an npm package. Firstly, install npm package.
C:\>npm install -g cordova
In IOS and LInux:
$ sudo npm install -g cordova
g is we are set this up as globally.
Create Your App
Navigate to the directory you want to install the application. Make sure you are root user or running these commands using
sudo. And run this command
cordova create demoapp com.test.app Hey!
Just this. Now you have create cordova app. Do this
Run this command to add whatever platform you want to add. You can check available platform. You can also check the requirement for a platform. For this run
cordova paltform android requirements
Before, you should have added the platform in your project. Do this
cordova platform add android
You can add any number of platform in your project. To know more about what you can do, run
cordova --help, cordova platform --help
We will setup environment for android platform. In android studio, you need
- jdk 8
Narmally, you would have Sdk in your android studio. If not, download it in sdk manager.
We have to setup environmental variables. It would be like for example,
for java ,
The above is enough to run the project.
Run on Device or Emulator
Make sure you are running these as root if you setup environment variables as root. You can install the app on android device via usb by running this.
cordova run android --device
Or on emulator
cordova run android
You can see the default cordova app running with their platform’s image on the device.
If you like it, share it with friends to keep writing more article. Reasonable criticism are most welcome.
For more articles, visit our website.