Using Cordova 9.0.0 with NetBeans 8.2

This brief guide shows how to make a few tweaks to fix some issues with Apache Cordova 9.0.0 projects in NetBeans IDE 8.2.

Netbeans Cordova Logo

Setup Cordova, NodeJS and Gradle

First, your system should be pre-configured with the Cordova, Node and Gradle shown below. This guide does not focus on how to install those components, these are relatively simple tasks.

Cordova, Node and Gradle versions

Cordova, Node and Gradle versions

Manage plugins with command line rather than NetBeans

Cordova plugins installed with the CLI will be removed by NetBeans on build time unless they have been added to the nbproject/ file beforehand. The following dialog allows managing the standard plugins, but you must not use it:

Do not use the NetBeans Cordova Plugins manager

Avoid using the NetBeans Cordova Plugins manager

Adding those default plugins will insert them to the file with an invalid source URL, such as this:

On build time, this will fail because the source URL is non existant. Probably there’s a NetBeans setting buried somewhere that allows changing this URL, however I was unable to find it.

Your options are to either:

A: Manually add them to with the correct URL, such as:

B: Manage plugins externally from the command line like this:

However, when using the external command line, the plugins you add will be removed on build time unless you have also added them to the file.

To prevent this, and switch to the command line only (forgetting about file entirely) follow these steps:

Open the nbproject/build.xml and replace this:

With this:

Save the file, and now whenever you build your app from NetBeans, it will neither install nor delete plugins. From now on, you must add/remove plugins with the cordova plugin add  and cordova plugin rm  commands.

Cordova plugins from NetBeans npm section

Cordova plugins from NetBeans npm section

You can still see that installed plugins from the npm Libraries item, and view their versions by accessing the npm Libraries Properties dialog.

Fix the Clean & Build and Clean Project buttons

NetBeans IDE Toolbar

NetBeans IDE Toolbar

If you have created an Apache Cordova app with the Cordova Hello World template, when using the globally installed Cordova CLI 9.0.0 your Clean/Clean and Build Project toolbar buttons will probably fail with this message:

1: Create a shortcut to your cordova.cmd executable (typically in C:\Users\Username\AppData\Roaming\npm) in your project’s root folder and rename it to cordova.cmd.

2: Open the nbproject/build.xml file and replace this:

with the following code, that replaces the (failed) gradlew command with the standard cordova.cmd shortcut we have just created:

Save and close this file.

Now you can use the Clean and Build Project and Clean Project toolbar buttons normally, and the project will be cleaned just like when you type cordova clean in the command line.

NetBeans Cordova Clean command output

NetBeans Cordova Clean command output

Please remember that this Build button generates a debug (unsigned) APK. To create a signed APK, use the build command from the command line with the -release option.

All product names, logos, and brands in this website are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.