If you want to learn how to develop Android & iOS Mobile apps using HTML, CSS, JS & Apache Cordova then enroll in my course here with 90% discount.
Apache Cordova - Build Hybrid Mobile Apps with HTML CSS & JS
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.
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 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.
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
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:
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.
Step 5: Edit index.html in www folder
Step 6: Edit index.js in www folder
Step 7: Edit index.css in www folder
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:
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
Top comments (4)
You forget to mention that this needs a Java Runtime Environment and the Android Studio installed and properly configured on your system and that is actually the hard part. Cordova actually does not install and set these up for you automatically just start complaining if they are missing when you try to build your project which is very dumb...
You are right. for beginners that is the important part. will try to add those point as well from next post.
why not editing this post and adding it, cuz some people might just simply thing they need cordova only and might do its setup and then realize they need android studio, which they might don't want to do so.
sure will edit this. thanks