Cordova development with Netbeans
written on March 4, 2014Coding HTML/JavaScript for web is fun. It is fun and it totally rules! but coding with HTML/JS for handhold devices is even more fun. The most exciting part is the large amounts of code which can be reused between different platforms and this is some dream for any developer.
However if you want to enter this area there are different approaches. They basically range from too abstract and really platform independent to too native and fitted to one platform's design and structure. Clearly as far as you go toward platform dependent solutions, the more code should be rewritten when porting your application to new platforms. The more you go toward platform independent solutions, the worse performance you will have.
There are solutions in this area which depend completely on native HTML5 and JS functionality provided by webview. And there are some solutions which provide you kind of self made JS and HTML interpretor to make it more solid.
In addition to portability and performance, any of these methods and any of their variations have their own pros and cons. You have to have in mind that for some usages such apps will never ever be like what you will have using native code. However there are fairly a large amount of applications that user will never feel the difference and where doing a native coding will only be waste of time. There is no one single cure for all problems, you have to investigate yourself to make sure if and which solution will pass to your need.
I'm not going to go through all these solutions nor I want to name them all, as some of them are totally commercial. What I experienced and proved to be a good solution FOR ME was using Cordova. You can just search for it and find learn materials, more that what I can ever write here. I just want to give you a kick start for setting up and using new Netbeans version for your development. Here I will only concentrate on Android.
Install Android SDK
If you dont want to have lengthy cycles of debugging, you will need Android SDK. Take your time to install it and then download SDKs of Android 4.3 (API level 18) from inside Android SDK Manager.
Install Netbeans 7.4
Next thing you will need, if you don't already have it, is Netbeans 7.4. I normally download the complete package, but if you don't need all of it, you need at least the HTML5 included package. Download and install it, this is the most promissing IDE after Visual Studio.
Install Cordova
You will need Node.js to install Cordova. If you are not familiar with Node.js don't freak out, as long as you don't get in his way, he will only help you. Just grab and install Node. Don't forget to include it in your command line path.
From here installing Cordova is as easy as typing one command:
npm install -g cordova
Starting Cordova project
From inside Netbeans you can easily start a new project and select a Cordova based project or just pickup a provided sample done with Cordova. If you are woundering where to find these all, use the search box in new project dialog to search for cordova.
Which project template you choose does not matter here, what is important is to press run from within Netbeans. There you will be provided with some settings which have to be set once. They are mainly setting path of SDK and so on. Do it now and once and you are good to go.
Deploying and running the app
The most exciting part is how easy is compiling and deployin on device. Basically all of these may also be done using command line, but believe me, it is much faster and easier using netbeans. The process is easy, you have to connect your android phone to your PC in developer mode and make sure it gets recognised by ADB.
$> adb devices
should output something like:
List of devices attached
0087e03f94c7a65b device
now going back to netbeans and just clicking on run will deploy and start the application on your device.
Further hints
Thats really interesting to see how easy is to use Cordova and Netbeans together for development. I have some other hints that will let your mouth fall open when it comes to debuging and remote inspection. They will go into a new post for later.