Developing Android Apps with NetBeans, Maven, and VirtualBox

Join the DZone community and get the full member experience.

I am an experienced Java developer who has used various IDEs and prefer NetBeans IDE over all others by a long shot. I am also very fond of Maven as the tool to simplify and automate nearly every aspect of the development of my Java project throughout its lifecycle.

Recently, I started developing Android applications and naturally I looked for a Maven plugin that would manage my Android projects. Luckily I found the maven-android-plugin which worked like a charm and allowed me to use Maven for developing my Android projects.

The Android Emulator from the Android SDK seemed unusably slow. Lucklily, I found a way to use an Android Virtual Machine for VirtualBox that worked nearly as fast as my native computer! This page documents my experiences.

Tested Environment

Overview of Steps

  1. Download and install the Android SDK on your dev machine
  2. Attach an Android Device to dev machine
  3. Configure and load your device for development and other use
  4. Create an initial Android maven project
  5. Connect Android Device to Android SDK
  6. Debug Android app using NetBeans Graphical Debuger

Download and Install Android SDK

export ANDROID_HOME=$HOME/android-sdk-linux_x86 #Change as needed
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"

Attaching an Android Device to Dev Machine

If you have an actual device that is usually always best. If not, you must use a virtual Android device which usually has various limitations (e.g. no GPS, Camera etc.). The Android SDK makes it easy to create a new Virtual Device but the resulting device is painfully slow in my experience and not usable. Do not bother with this. Instead, create a virtual Android device using VirtualBox as described in the following steps:

Configuring your Android Device

This section describes various things I did to setup a dev environment for my Android device:

Creating Initial Android Maven Application

Connecting Android VM Device to Android SDK

In order for your code to be deployed from NetBeans IDE to Android Device and in order for you to monitor your deployed app from the Dalvik Debug Monitor (ddms) you need to connect your android VM device to the android sdk over TCP as described in the following steps.

setprop service.adb.tcp.port 5555
stop adbd
start adbd
adb tcpip 5555
adb connect 192.168.0.101:5555

For details on above steps see:

Now for the acid test whether you can deploy your app to the device from NetBeans IDE!

If all is well, the app will deploy to the device and will show up in its "Applications" screen.

Debugging Android App Using NetBeans Graphical Debugger

Once you can build and deploy your app to the real or virtual Android device, here are the steps to debug the app using NetBeans debugger:

Android (robot) app NetBeans Apache Maven Virtual Machine Android SDK VirtualBox dev Machine Software development kit

Opinions expressed by DZone contributors are their own.