Netbeans 8.0 Cordova Projects

It took me ages to get the Netbeans 8.0 Cordova project plugin for HTML5 mobile applications up and running.  The steps needed are detailed below in the hope that they might help someone else who is struggling.

These notes relate to Netbeans 8.0.2 on Ubuntu 15.04, but they should be sufficiently general to be of use to just about anybody trying to get this to work, whatever platform Netbeans is running on.  The steps are

  • Install Node.js (the installer is at the Node.js site).
    • This installs Node.js and npm (the Node Package Manager).  On Ubuntu, this turned out to be a better option than installing Node.js via the package manager for two reasons:
      • No need to link the /usr/bin/nodejs to /usr/bin/node
      • The repository version is too old for Cordova (or at least I got a warning to that effect.  It may have worked, but I didn’t check).
    • Test by opening a terminal and typing ‘node -v’ at the prompt.  You should get back a message telling you you have node version 0.12.7 (or whatever version you installed).
  • Next, install git if you don’t already have it.  Instructions can be found at the git-scm site.  Obviously if you’re running Linux, your best option is to use your package manager.
  • Download and install the Android SDK.
    • Unless you particularly want the Android Studio IDE, you just want the standalone SDK tools
  • Add SDK packages  to the Android SDK.
    • This can take a very long time.  For me, each of the system images took over ten minutes to download, so make sure you have a couple of hours spare for this step.
  • Set up an ANDROID_HOME environment variable.  You need to make it persistent.  I did this by putting the command (export ANDROID_HOME=/path/to/android/sdk) in my .profile, but things may be different on Windows and Mac boxes.
  • Now you have the prerequisites, you can install Cordova using npm.
    • Basically, you just do (at the command prompt as root/sudo, or whatever you have to do on a Mac or Windows box):
      • npm install -g cordova
      • You may get a warning about the node.js version, but it doesn’t seem to harm anything.
  • Open NetBeans and use the Plugins Manager at Tools -> Plugins to install the Cordova plugin.
  • Set up NetBeans for Cordova projects by going to Tools -> Options.
    • Select the Miscellaneous section, and then the Mobile Platforms tab.
    • Enter the location of the Android SDK (wherever you put it).
      • If you see an error message asking you to set ANDROID_HOME, you’ll know you haven’t set the environment variable up correctly.
  • Create a Cordova project, under the HTML5 category of New -> Project.  There’s a ‘Cordova Hello World’ example project you can use.

Not exactly child’s play, but it looks pretty good once you’ve set it up.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *