How to Create Android & iOS Mobile App using HTML, CSS & JavaScript
Tags: android, ios, cordova, javascript
Published: 2020-02-18 22:41:47

**Apache Cordova** is an open-source mobile development framework. It allows you to use standard web technologies such as HTML5, CSS3, and JavaScript for cross-platform development, avoiding each mobile platform native development language. Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to access each device’s sensors, data, and network status.”

If you want to learn how to [develop Android & iOS Mobile apps using HTML, CSS, JS & Apache Cordova] (https://www.udemy.com/course/cordova-hybrid-app-development-for-android-and-ios/?referralCode=E65798C059452FD4377E) then enroll in my course here with 90% discount.

[Apache Cordova - Build Hybrid Mobile Apps with HTML CSS & JS] (https://www.udemy.com/course/cordova-hybrid-app-development-for-android-and-ios/?referralCode=E65798C059452FD4377E)

In this blog post, I’ll show you how to Create your first Cordova Project for Android, iOS, Browser, and Desktop using HTML, CSS, and JavaScript.

By Cross-Platform, we mean that the application codebase can be written once using HTML5, CSS3 & JavaScript and it can be run across multiple target mobile platforms such as Android, iOS, Windows, Firefox, Ubuntu mobile.

The web development community has been continually innovating and with the recent development of frameworks such as Angular, IONIC, jQuery and React, the traditional web applications have now almost become indistinguishable from their native platform-specific peers in terms of functionality.

Apache Cordova can be extended with native plug-ins, allowing developers to add more functionalities that can be called from JavaScript, making it communicate directly between the native layer and the HTML5 page. These plugins allow access to the device’s accelerometer, camera, compass, file system, microphone, and more.

However, the use of Web-based technologies leads some Apache Cordova applications to run slower than native applications with similar functionality.

And the most important thing is: Cordova is free and open source. Here’s how to get started with Apache Cordova.

#Use [Apache Cordova](https://androidabcd.info/how-to-create-apache-cordova-app-using-cordova-cli/) if you are:

* a mobile developer and want to extend an application across more than one platform, without having to re-implement it with each platform’s language and toolset.
* a web developer and want to deploy a web app that’s packaged for distribution in various app store portals.
* a mobile developer interested in mixing native application components with a WebView (special browser window) that can access device-level APIs, or if you want to develop a plugin interface between native and WebView components.


If you would like to watch and learn from video then you must watch on YouTube and also subscribe to the “Instill Learning” YouTube channel for a future tutorial.

{% youtube IwOXZpjBCSU %}

#Prerequisite#
Before creating a new Cordova App, there are few prerequisites and you have to install this software:

*Node.js (npm comes with Node.js) [ https://nodejs.org/en/ ]
*Cordova [after installing node.js, you can install cordova through command line or terminal by using following command “npm install -g cordova“] [ https://cordova.apache.org/#getstarted ]

##Step 1: Create a new Cordova App
 _cordova create DeviceInfo info.androidabcd.deviceinfo DeviceInfoSample_

**After creating the new app, move to Cordova project folder**

 _cd DeviceInfo_

##Step 2: Add the Android platform
 
_cordova platform add android@latest_

##Step 3: Add plugin to get device information
 
_cordova plugin add cordova-plugin-device_

By using this plugin you get the following device information:

* device.cordova
* device.model
* device.platform
* device.uuid
* device.version
* device.manufacturer
* device.isVirtual
* device.serial

##Step 4: Open code in Visual Studio Code Editor
If you haven’t install visual studio code then download and install from here: https://code.visualstudio.com/

You can open the Cordova project from the command line or terminal by typing ” code . ” [code space dot], or you can directly drag & drop the project into visual studio code.

![Open code in visual studio code](https://i1.wp.com/androidabcd.info/wp-content/uploads/2020/01/Screenshot-2020-01-26-at-3.55.08-PM.png?resize=1536%2C963&ssl=1)


##Step 5: Edit index.html in www folder

{% jsfiddle https://jsfiddle.net/instilllearning/7y08c4ed/ html %}



##Step 6: Edit index.js in www folder

{% jsfiddle https://jsfiddle.net/instilllearning/7y08c4ed/ js %}

##Step 7: Edit index.css in www folder

{% jsfiddle https://jsfiddle.net/instilllearning/7y08c4ed/ css %}


##Step 8: Prepare the Cordova project
After editing the source code in www folder, you must prepare the code, so that it can distribute to all platforms you have added. to prepare the source code type following command in the command line or terminal:

_cordova prepare_

##Step 9: Build Cordova Project
Once you build your Cordova project, you will notice that it will generate APK File and that you can install it manually in any Android device. Or if you want to install the app using the command line then see the next step.

_cordova build android_

##Step 10: Run Cordova App in Android Emulator
You have to run Android Emulator before running this command.

_cordova run android_


How to run an Emulator

##Step 11: Up and Running Cordova App in Emulator
![Device Info] (https://i0.wp.com/androidabcd.info/wp-content/uploads/2020/01/Screenshot-2020-01-26-at-4.06.34-PM.png?resize=1536%2C1108&ssl=1)