Home > Articles > Mobile Application Development & Programming

What's New in Apache Cordova 4?

The latest version of the open source framework Apache Cordova brings many changes, particularly in the command-line interface, plugins, and WebView. John M. Wargo, author of Apache Cordova 4 Programming, points out his favorite features and others whose improvements will simplify your development process.
Like this article? We recommend

Like this article? We recommend

In this article, I'll provide an update on the latest major release of Apache Cordova, a popular open source framework for hybrid applications. A lot of interesting things are happening as Cordova becomes an even more important part of many organizations' mobile application strategy.

Apache Cordova is a free, open source framework for building cross-platform native applications using HTML5. The creators of Apache Cordova wanted a simpler way of building cross-platform mobile applications and decided that the best approach was to use a combination of native and web technologies. This type of mobile application is called a hybrid application.

Cordova is used for consumer applications as well as many enterprise applications. On the consumer side, many games and personal applications have been built using the platform. On the enterprise side, Cordova has been widely adopted by many companies, as well as being included in the development platforms that software companies sell to enterprises. Examples:

  • Adobe PhoneGap is a downstream distribution of Apache Cordova with some extra stuff added. On the PhoneGap website, you can browse a catalog of consumer apps built with the technology. Adobe recently released the PhoneGap Enterprise app to help organizations distribute content to remote users.
  • Apache Cordova can also be found in IBM Worklight, an enterprise mobile application development platform (MADP) from IBM, as well as products from Oracle, Salesforce.com, and many others.
  • Until recently, I was responsible for the SAP Mobile Platform hybrid SDK, a set of enterprise plugins for Apache Cordova from SAP.

Because of all of this attention, a lot of people are working on Apache Cordova. The most interesting piece for me is how the different device manufacturers have gotten onboard with the project. Development teams from Amazon, BlackBerry, Google, Intel, Microsoft, Mozilla, Ubuntu, and more are involved. Pretty much everybody in the smartphone space (except for Apple) has made an investment in the project.

So what's changed in the latest release of Apache Cordova? A few big things, but not very much overall. The Cordova team works diligently to add new platforms whenever possible. A couple of new APIs have cropped up lately, but for the most part the dev team seems more interested in removing APIs than adding new ones. Features generally make it into the product as soon as they're ready.

In the rest of this article, I'll highlight what I see as the big parts of this latest version of Apache Cordova.

Release Strategy

The Cordova team is constantly working to improve the framework. In the Cordova 3 timeframe, framework releases were a big deal and appeared on a regular near-monthly cadence. With the later releases, the Cordova team has broken out the different components into individual release plans. Instead of the Cordova core, command-line interfaces (CLIs), and plugins all being bundled together for a formal release, everything has been broken out into separate release schedules. As an example, when the team working on a particular plugin for a particular platform is ready, the plugin is released. One team doesn't have to wait for all of the other platform teams to coordinate their efforts; instead, each team simply completes its work, tests everything, votes on a release, and then releases it. The same thing is true for the Cordova CLI. As capabilities (or bug fixes, of course) are added to the CLI, it is released when ready, instead of waiting for the other components to be ready as well.

With so many teams working on components in parallel, it's been challenging to sync to a solid release cadence. As an example, version 4 of the Cordova CLI was released right before PhoneGap Day in October 2014, but the Android platform version with the pluggable WebView (described later) wasn't released until March 2015.

Because of potential compatibility issues between the CLI and target platforms, each CLI release is pinned to a specific set of platform releases. If you want to add a specific newer platform to your project, you will need to append the platform release to the platform name in the cordova CLI command. For example, to add an Android platform to an existing project, you use the following command:

cordova platform add android

The Cordova CLI will add the Android platform version that has been associated with that CLI release. To add a newer platform than was pinned to the CLI, add the platform version to the command:

cordova platform add android@platform_version

For example, to use the Android 3.7.1 platform in your project, you would issue the following command:

cordova platform add android@3.7.1

Look at the release notes for any specific version of the Cordova CLI; the Cordova team should publish the list of pinned platform versions for that release.

Command-Line Interfaces

Cordova provides two CLIs: the Cordova CLI that simplifies the process of working with a Cordova project; and Plugman, a set of command-line tools for managing Cordova plugins. Plugman came first, as a way to help plugin developers create new plugins and add them to their Cordova projects. The Cordova CLI (which uses Plugman under the covers) was developed later as a way to help the everyday hybrid application developer work with Cordova projects. Although sometimes developed by different teams, over time the Cordova developers noticed some common functions used by both Plugman and the CLI. In an effort to simplify the development workload for these two tools, the Cordova team created a set of common libraries that are used by both CLIs.

These common libraries don't really affect the end user of these tools, but they help align how both CLIs operate, simplifying the development effort required to work on the tools.

Save/Restore Plugins

In older versions of Apache Cordova, the Cordova application project was closely bound to the development environment on the system where the application was created. The Cordova CLI interacted with the local mobile platform SDKs, and it was really hard for one developer to give another developer access to the project if the target system wasn't running the same version of almost everything.

With the Cordova CLI 4.0 release, the team added commands that allow a developer to store plugin information for the project in the application project's config.xml file. The commands were experimental in that release, so you had to add a special flag on the command line to utilize them, but the capabilities were in place. At the time of writing, this capability was to be moved from experimental status to production. (At this point, it might already have been moved.)

To take advantage of these capabilities, the developer will use the Cordova CLI to save the plugin configuration and then pass the project's config.xml file and the contents of the project's www folder to another system or developer. With the files in place on the new system, a simple Cordova CLI command will restore the listed plugins to the project in its new location.

Pluggable WebView

The WebView is a native application component that renders the web application content in a Cordova application. It's essentially a browser window you can embed in a native mobile application. Until recently, Apple and Google implemented the native WebView using a different rendering engine than the one found in the native browser. This design had the potential side-effect of making a hybrid application run slower than the same content would run in the native browser. Additionally, with different rendering engines in play, a web application could render correctly in the native browser but not so well in the WebView. Both companies have now resolved this issue with newer devices; for the most part, the WebView now uses the same rendering engine as the browser.

In January 2015, Google announced that it would no longer back-port bug fixes to older versions of the WebView used by Apache Cordova. This change wasn't because of Cordova, but certainly affects Cordova developers in a big way. If your application encounters a rendering problem when running on an older Android device, you're pretty much out of luck in this situation.

The Cordova team is planning a solution to this problem. Soon, developers will be able to add a compatible WebView to a Cordova project by using a new command added to the Cordova CLI. The first implementation is through the Intel Crosswalk Project. Crosswalk is a browser runtime engine that uses the latest version of the Blink rendering engine. On modern Android smartphones, Blink is already the engine distributed by Google. Where Crosswalk becomes important is on older devices where Google is no longer providing bug fixes. Crosswalk will be implemented first, and other options will be made available as well.

Third-Party Tools Support

Not part of the Cordova release, but interesting anyway, is how many third parties have added support for Cordova to their products. One of the goals of the Cordova CLI is to provide tooling that can be consumed by other tools; Cordova provides the "plumbing," and you use whatever tools you want to code, test, debug, and build your Cordova apps.

As I worked on my latest Cordova book, I noticed plenty of third-party tools and frameworks available now that specifically target hybrid development or are Cordova-aware. The Ionic framework, for example, is an open source HTML5 framework specifically targeting hybrid applications like Cordova applications. Another is Onsen UI, which is billed as being Cordova/PhoneGap-friendly. Developers working on hybrid applications will find a lot of frameworks out there built with Cordova in mind.

On the tooling side, Adobe finally released the Brackets open source text editor after announcing it several years ago. This awesome editor is easily enhanced through a robust catalog of third-party plugins for Adobe PhoneGap as well as Apache Cordova. It's a great tool for managing your Cordova projects.

I was recently introduced to the JetBrains WebStorm IDE. What's cool about this tool is its built-in Cordova and PhoneGap integration. Simply enable the appropriate options, and suddenly you can issue Cordova CLI commands directly from within the IDE.

The Eclipse Foundation recently released the Hybrid Mobile project (with the acronym THyM), which is a specific set of tools for building hybrid applications based on the Eclipse IDE. This project was started by the folks in Red Hat's JBOSS team, and it allows you to manage the entire Cordova project lifecycle from within Eclipse.

The most important tool release (in my eyes) is Microsoft's Visual Studio Tools for Apache Cordova. This plugin to Visual Studio adds a complete solution for managing your Cordova projects in Visual Studio. Not only do you get Cordova-specific tools for Windows applications, but the team working on the toolkit added support for JavaScript debugging of Android and iOS applications—all from within Visual Studio. With this tool, you can create a Cordova project for those platforms and do live, real-time JavaScript debugging, all from within visual Studio. Open an application project, set one or more breakpoints in the application's JavaScript code, and the debugger will halt application execution at the breakpointed lines and let you step through the code, view variable contents, and more on all supported platforms. Really cool stuff.

For details on all of these topics (and more ), see my book Apache Cordova 4 Programming.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020