Building an Ionic Application using Cordova for Android

Reading Time: 2 minutes

Ionic Framework is an open-source UI toolkit for building performant, high-quality mobile, and desktop apps using web technologies (HTML, CSS, and JavaScript). Ionic Framework is focused on the frontend user experience, or UI interaction of an app (controls, interactions, gestures, animations). It’s easy to learn and integrates nicely with other libraries or frameworks, such as Angular, or can be used standalone without a frontend framework using a simple script include.

About Cordova

Cordova is an open-source framework for creating “hybrid” mobile applications. The beauty of Cordova is that it allows developers to leverage their knowledge of web development to build mobile applications on a number of different platforms. Using standard HTML, CSS, and JavaScript, a developer can create applications for Apple, Android, and Windows phones without the need for knowledge of each of those platforms’ native languages. Additionally, Cordova has a number of plugins that allow the developer to interact with native features of the phone via JavaScript. Using Cordova, we can add plugins that will allow our application to interact with the device’s camera, geolocation, send notifications, and many other features.

Steps to create and build an Ionic Application on Cordova Android Platform

  • Node setup
  • Cordova setup
  • Create an Ionic Application
  • Publishing your app

Node Setup

# Check the version for Node
node -v
v10.16.0

# Check the version for NPM
npm -v
6.9.0

Cordova Setup

# Install Cordova using npm
npm install -g cordova

# Check the version of Cordova
9.0.0 (cordova-lib@9.0.1)

Create an Ionic Application

Firstly, we have to create an ionic application using npm by following commands:

npm install -g ionic
ionic start myApp

To run your application on the local server using the following commands:

cd myApp
ionic serve

Publishing your app

To publish the ionic application to the app store, firstly we have to add android platform to the application using the following CLI command:

sudo ionic cordova platform add android

This command directly adds the default ionic icons and splash screen resources and provide friendly checks. To remove the android platform just replace the add keyword with remove. Now generate the build for android, by using the following command:

sudo ionic cordova build --release android

This will generate the release build on the settings in your config.xml. Now you can locate your apk file of an application under the following directory:

myApp/platforms/android/app/build/outputs/apk/release/app-release.apk

Now your app is ready to use.

See the Ionic Docs for further Ionic development.

Build Ionic Application

Written by 

Rudar Daman Singla is the Trainee Software Consultant at Knoldus Software LLP. He has done B.Tech. from Jaypee University of Information technology, Waknaghat(Solan). He has good knowledge of languages C, C++, Java, Scala, HTML, CSS, PHP, Node and Angular. He is also interested in VFX. As a fresher, he always tries to explore the different type of software and tools.