Categories: AndroidMobility

Cordova Hello World with Android & Eclipse IDE

This article is aimed to get you started with Cordova, an open-source mobile development framework, with Eclipse IDE and write your first Android app, Hello World. Read about what is Cordova, how & who should use it on this page.

Following will be detailed in this article:

  • Why Cordova?
  • Setup Cordova with Android
  • Create Cordova Hello World App with command-line interface (CLI)
  • Setup Cordova Hello World App into Eclipse
Why Cordova?

Following are some of the reasons why you would want to use Apache Cordova mobile app development framework. Well, following can be same for other Mobile development framework such as Titanium.

  • If you are a web developer and want to deploy a web app that’s packaged for distribution in various app store portals. This is very useful for web developers wanting to distribute their web app as mobile app to different app stores.
  • Second common use case is that 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 tool set, Cordova could prove to be helpful.
  • Third use case specific to Cordova is that if you are a mobile developer interested in mixing native application components with a WebView (browser window) that can access device-level APIs, Cordova can help a great deal.

 

Setup Cordova with Android

To work with Cordova, one would require to install Cordova command line interface (CLI). Following are some of the tools one need to install before setting up cordova:

  • Install Java and include “bin” folder in the path such as %Java_HOME%\bin.
  • Download and install Node.js
  • Download and install Git Client
  • Download and setup Ant. As part of setup, define ANT_HOME as path variable and include %ANT_HOME%\bin in the path.
  • Download and setup Android SDK. Download android SDK from android page. As part of setup, create ANDROID_HOME environment variable and include %ANDROID_HOME%\platform-tools.

I started without last two steps and was unable to get going with Cordova CLI. Once all of the above is done, execute following as per instruction on this cordova page, and you would be done with Hello World. Execute following command to install and setup cordova.

execute npm install -g cordova

 

Cordova Hello World App with CLI

With Cordova setup done, create a cordova folder and do the following to setup the Hello World app from within that folder.

  • Execute the command, “cordova create hello com.example.hello HelloWorld“. Read the instruction on what the command does on following cordova page.
  • Goto “hello” folder (cd hello) and execute following command to add Android platform. “cordova platform add android“.
  • Execute the build command using “cordova build“. This would generate platform-specific code within the project’s platforms subdirectory.
  • That is it. You are all set to test the app in an emulator. Execute “cordova emulate android“.

 

Setup Cordova Hello World App into Eclipse

I did spend some time to figure out that you would need an IDE to develop with Cordova platform. You could as well use any text editor to work with Cordova platform because what you work with are HTML, CSS and Javascript files. Install Eclipse IDE and do the following steps:

  • Create a project
  • Import the code generated using cordova CLI into your eclipse
  • Start modifying index.html. As this is an HTML page, if you have experience with HTML, CSS and Javascript, write anything and get it shown in the Android emulator.
  • Execute “cordova build” and “cordova emulate android” to see the updates on emulator.

[adsenseyu1]

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Share
Published by
Ajitesh Kumar
Tags: cordova

Recent Posts

Agentic Reasoning Design Patterns in AI: Examples

In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…

1 month ago

LLMs for Adaptive Learning & Personalized Education

Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…

1 month ago

Sparse Mixture of Experts (MoE) Models: Examples

With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…

2 months ago

Anxiety Disorder Detection & Machine Learning Techniques

Anxiety is a common mental health condition that affects millions of people around the world.…

2 months ago

Confounder Features & Machine Learning Models: Examples

In machine learning, confounder features or variables can significantly affect the accuracy and validity of…

2 months ago

Credit Card Fraud Detection & Machine Learning

Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…

2 months ago