Twitter: http://twitter.com/#!/farrukhn Web: http://www.wellfleetsoftware.com/farrukh Blog: http://www.wellfleetsoftware.com/blog/farrukh Farrukh has posted 1 posts at DZone. View Full User Profile

Developing Android Apps with NetBeans, Maven, and VirtualBox

06.18.2011
| 104182 views |
  • submit to reddit

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

  • Dev machine: Ubuntu 11.04 Linux
  • IDE: NetBeans
  • VirtualBox: 4.0.8 r71778
  • Android SDK Revision 11, Add on XML Schema #1, Repository XML Schema #3 (from About in SDK and AVD Manager)
  • Android Version: 2.2

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

  • Download and install the Android SDK on your dev machine as described here.
  • Make sure to set the following in dev machine ~/.bashrc file:
    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.

  • On Android Device open the Terminal Emulator
  • Type su to become root (your device must be rooted for this
  • Type following commands in root shell:
    setprop service.adb.tcp.port 5555
    stop adbd
    start adbd
  • Type the following commands on dev machine shell. TODO: Note that IP address below is whatever is the ip address associated with the device (see ifconfig on linux for device vboxnet0)
    adb tcpip 5555
    adb connect 192.168.0.101:5555

For details on above steps see:

http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp

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

  • Right-click / Custom / Goal to show Run Maven dialog.
  • Enter android:deploy in Goals field.
  • Select Remember As button and enter android:deploy for its text field.

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:

  • On Device: Start the app (TODO: determine how to start app on device with JVM options so it can wait for debugger connection. This should be easy)
  • On Dev Machine run Dalvik Debug Monitor (ddms) in background: $ANDROID_HOME/tools/ddms &
  • Lookup your app in ddms and get its debug port. This is described here but does not address NetBeans specifically
  • In NetBeans do: Debug / Attach Debugger and specify the port looked up in ddms in previous step. You may leave rest of the fields with defaults. Click OK

 

Published at DZone with permission of its author, Farrukh Najmi.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Imam Sulistio replied on Mon, 2013/12/23 - 6:28pm

I never read such beautiful article before. If you ever want to take some of the load off, I'd love to write some material for your blog in exchange for a link back to mine. Please shoot me an email if interested. Thank you grosir tanah abang

Muhammad Danial replied on Fri, 2014/03/28 - 3:17am

 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. 

Visit this link

Muhammad Danial replied on Sat, 2014/03/29 - 7:56am

  I have bookmarked this webpage and I am visiting the site in the upcoming days.  

günstig

Muhammad Danial replied on Wed, 2014/04/02 - 2:37am

   At the end of the day, under the Senate bill subsidies would continue to benefit the largest agribusinesses, with the lion’s share of dollars flowing to corn and soy. 

Doing a Business Plan

Muhammad Danial replied on Thu, 2014/04/03 - 11:01am

 Click here 

 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.


Muhammad Danial replied on Sun, 2014/04/06 - 9:01am

 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. 

anti wrinkle serum

Muhammad Danial replied on Mon, 2014/04/07 - 5:38am

 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.

empresas energías renovables

Muhammad Danial replied on Mon, 2014/04/07 - 7:58am

 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.

Click here

Black Men replied on Wed, 2014/04/09 - 4:50am

 Easily, This excellent article assisted me very much! Saved your site, extremely great categories everywhere that I read here!  

magnetic whiteboards

Black Men replied on Thu, 2014/04/10 - 1:29am

 At the end of the day, under the Senate bill subsidies would continue to benefit the largest agribusinesses, with the lion’s share of dollars flowing to corn and soy.

risperdal

Black Men replied on Thu, 2014/04/10 - 8:35am

 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.

Check this site

Samad Khatri replied on Mon, 2014/04/14 - 8:34am in response to: Piero Sartini

 be deployed from NetBeans IDE to Android Device and in order for you to monitor your deployed app from the cheapest flowers by post 

Black Men replied on Tue, 2014/04/22 - 4:06am

 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. 

amanda leto fibroids miracle book

Jakie Mac replied on Tue, 2014/04/22 - 7:42am

 On Device: Start the app (TODO: determine how to start app on device with JVM options so it can wait for debugger connection. This should be easy)

<a href='http://www.speakoutsmallbusiness.com/view-post/Kenneth-Eng-asks-Where-are-We-and-Where-are-We-Going' >Check this site</a>

Black Men replied on Tue, 2014/04/22 - 1:18pm

 Configuring your device' section above. Universal Androot installs fine (latest version) but when you try to root the device, it comes back with the message 'Cannot root this device :('. Did you use any particular version of Universal Androot?  

get more Facebook Followers

Black Men replied on Thu, 2014/04/24 - 4:01am

  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. 

blog url

Black Men replied on Mon, 2014/04/28 - 11:11am

  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.

Buy Targeted Traffic

Jakie Mac replied on Wed, 2014/05/07 - 1:08am

 Install ConnectBot so you have ssh and related network

Jeff from PopularWorkouts.com

Jakie Mac replied on Wed, 2014/05/07 - 4:56am

 Android SDK Revision 11, Add on XML Schema #1, Repository XML Schema #3 (from About in SDK and AVD Manager)

Jakie Mac replied on Thu, 2014/05/08 - 7:39am

 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. 

Click here

Jakie Mac replied on Thu, 2014/05/08 - 8:38am

 VirtualBox that worked nearly as fast as my native computer! This page documents my experiences.

http://WhiskyReview.net/the-ultimate-guide-to-jack-daniels

Jakie Mac replied on Sat, 2014/05/10 - 5:04am

 Configure Android VM so it is connected bidirectionally with your dev machine over TCP as described here:

Brian Ludmer blog

Sam Su replied on Wed, 2014/09/10 - 10:57pm in response to: Michael Paitl

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration about java development,i got a ulefone 7.0 inch  device testing project, both of which I need, thanks to offer such a helpful information here,i would like to test android application on my ulefone smartphone .

Ray Naa replied on Sun, 2014/10/05 - 3:45pm

 

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.
 
Odd Family

Ray Naa replied on Sun, 2014/10/19 - 5:50pm

 

Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work!!!
 
tropical fish

Ray Naa replied on Wed, 2014/10/29 - 9:25am

 

Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.
 
la voyance

Ray Naa replied on Wed, 2014/10/29 - 9:27am in response to: Matt Coleman

 

Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have.
 
la voyance

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.