Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Cordova's first application

May 21, 2021 Cordova

Table of contents

In the last tutorial, we showed you how to install Cordova and set up the environment. /b10> Once everything is ready, we can create our first hybrid Cordova application.

Step 1 - Create an application

Open the directory where you want to install the application under the command prompt. /b10> We'll create it on the desktop.

C:\Users\username\Desktop>cordova create CordovaProject io.cordova.hellocordova CordovaApp
  • CordovaProject is the directory name that creates the application.

  • io.cordova.hellocordova is the default reverse domain value. /b10> If possible, you should use your own domain values.

  • Cordova App is the title of your app.

Step 2 - Add a platform

You need to open your project directory at the command prompt. /b10> In our example is CordovaProject. /b11> You should only choose the platform you need. /b12> In order to be able to use the specified platform, you need to install a specific platform SDK. /b13> As we develop on Windows, we can use the following platforms. /b14> We also have an Android SDK installed, so we'll only install Android for this tutorial.

C:\Users\username\Desktop\CordovaProject>cordova platform add android

There are other platforms available on the Windows operating system.

C:\Users\username\Desktop\CordovaProject>cordova platform add wp8

C:\Users\username\Desktop\CordovaProject>cordova platform add amazon-fireos

C:\Users\username\Desktop\CordovaProject>cordova platform add windows

C:\Users\username\Desktop\CordovaProject>cordova platform add blackberry10

C:\Users\username\Desktop\CordovaProject>cordova platform add firefoxos

If you are developing on a Mac, you can use -

$ cordova platform add IOS

$ cordova platform add amazon-fireos

$ cordova platform add android

$ cordova platform add blackberry10

$ cordova platform add firefoxos

You can also remove platform use from your project -

C:\Users\username\Desktop\CordovaProject>cordova platform rm android

Step 3 - Build and run

At this point, we're building an application for the specified platform, so we can run it on a mobile device or emulator.

C:\Users\username\Desktop\CordovaProject>cordova build android

Now we can run our application. If you use the default simulator, you should use -

C:\Users\username\Desktop\CordovaProject>cordova emulate android

If you want to use an external simulator or a real device, you should use -

C:\Users\username\Desktop\CordovaProject>cordova run android

Note - We will use the genymotion android simulator because it is faster and more sensitive than the default. /b10> You can find it here. /b11> You can also test with an actual device by enabling USB debugging from the options and then connecting it to your computer via a USB cable. /b12> For some devices, you also need to install USB drivers for specific devices.

Once we run the application, it will be installed on our designated platform. /b10> If everything is done without errors, the output should show the application's default start screen.

Cordova's first application

In the next tutorial, we'll show you how to configure the Cordova application.