"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Saturday 13 October 2012

Android Development on Netbeans (and the EEEPC)


In my previous post I moved my first steps in Android development world by installing Android SDK and Eclipse IDE on my desktop computer. After successfully writing my first Android hello-world I went, almost immediately, on how to do Android development on the EEEPC 900. If it's true the desktop computer is much more suited for writing code it's the EEEPC tho one I always bring with me and I use for my experiments.
I'm a big fan of Eclipse and I use it everyday at work but, when it comes using it on a netbook, it performs very poorly. Worst of all some Eclipse configuration windows are too big to fit into the small EEEPC screen and even lack of scroll-bars. This is why I use Netbeans on the EEEPC. After a brief looking-up on the 'net I came to NBAnroid plug-in page.

Installing Netbeans to 7.2

Even if it isn't required I decided to upgrade my Netbeans installation to the latest 7.2 version. I so removed previous version by launching Netbeans removal script
sudo /usr/local/netbeans-7.1.2/uninstall.sh
then I downloaded latest Netbeans version from its download page and launched the auto-installing script
chmod +x netbeans-7.2-ml-javase-linux.sh
sudo ./netbeans-7.2-ml-javase-linux.sh
this started the usual Netbeans installation wizard 
after some “I agree” and several “Next” I got the new version installed.

Installing Android SDK

Like in my previous post I downloaded Android SDK from Google's page and extracted it on my home folder
mkdir android
mv Downloads/android-sdk_r20.0.3-linux.tgz android/
cd android/
tar -xf android-sdk_r20.0.3-linux.tgz


Installing NBAndroid plug-in

I installed then the NBAndroid plug-in from Netbean's plug-in manager:
I selected the “Add ...” button in the “Settings” tab and went into the update center customizer 
where I did set the plug-in update URL (plug-in for older Netbeans versions has a different URL).
Then I selected “Android” from the available updates
by pressing “Install” the plug-in installation wizard started, NBAndroid has a dependency with the Android-Lint plug-in
after the usual License agreement and a warning about the plug-in being signed from a not-trusted certificate the installation completes. I then set the Android SDK path in Netbeans options (in the Miscellaneous/Android tab)
Then I started the Android SDK manager (there is a “”Android and AVD Manager” item in the “Tools” menu)
I then selected “Android SDK Platform Tools” and “Android 4.1 (API 16)” for download. Because of the smaller disk space on the EEEPC I've been able to install only one Android API version. Not a big problem since the netbook is not going to “production” computer but only one for experiments. After some more downloading I've been able to write my first Application.

First Application

I selected “Android Project” from the “New Project” window and I got the new Android application window where I cold set basic application parameters: name, package, activity name and target platform.
After selecting “Finish” I got my hello-world project ready.
at the beginning I was a little startled seeing the code marking en error at the line
setContentView(R.layout.main());
looking for it in the 'net I discovered that this plug-in, unlike the eclipse one, writes the automatically generated class “R” only after the first build command. After pressing the build button the error mark in fact disappeared.

First Run

Like with Eclipse you can run your Android application just by hitting the run or the debug button. I tried using a virtual device, after by defining it with the AVD Manager but it's so painfully slow to load. So running an application on a real device is the only viable solution on low performances computers like the EEEPC. After editing the “51.android.rules” file just like in my previous post the new hello-world application has been regularly deployed to my phone.

4 comments :

  1. We use Eclipse in developing Android apps. But netbeans is also my recommendations. :)
    philwebservices

    ReplyDelete
    Replies
    1. Thanks for visiting Kit!

      I too prefer working with Eclipse on desktop computers but on the EEEPC is almost unusable.

      Delete
  2. am facing a problem with the Netbeans after i added the URL its okay but when i search for the plugin android i couldnot find it
    am using Ubuntu 12.10
    and netbeans 7.2.1
    thnk you

    ReplyDelete
    Replies
    1. Thanks for visiting Feras,

      Check if the URL is correct, do you get any error message in the process?

      Delete