DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Allow Users to Track Fitness Status in Your App
  • How to Build a React Native Chat App for Android
  • Simplifying Database Operations With HarperDB SDK for Java
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline

Trending

  • DGS GraphQL and Spring Boot
  • Event-Driven Architectures: Designing Scalable and Resilient Cloud Solutions
  • Immutable Secrets Management: A Zero-Trust Approach to Sensitive Data in Containers
  • MySQL to PostgreSQL Database Migration: A Practical Case Study
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Developing Android Apps with NetBeans, Maven, and VirtualBox

Developing Android Apps with NetBeans, Maven, and VirtualBox

By 
Farrukh Najmi user avatar
Farrukh Najmi
·
Jun. 18, 11 · Tutorial
Likes (0)
Comment
Save
Tweet
Share
172.9K Views

Join the DZone community and get the full member experience.

Join For Free

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:

  • Install virtual box and initial Android VM as described here:
    http://androidspin.com/2011/01/24/howto-install-android-x86-2-2-in-virtualbox/

    http://geeknizer.com/how-to-run-google-android-in-virtualbox-vmware-on-netbooks/
  • Configure Android VM so it is connected bidirectionally with your dev machine over TCP as described here:
    http://stackoverflow.com/questions/61156/virtualbox-host-guest-network-setup

    I used the approach of configuring a HOST ONLY network adapater and a second NAT adapter on the Android VM within virtual box.


Configuring your Android Device

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

  • Root the device. I used Universal AndRoot
  • Install ConnectBot so you have ssh and related network utilities


Creating Initial Android Maven Application

  • Create initial project using instructions here.
  • I found it best to create stub project structure using the maven-archtype-plugin and the archtypes at https://github.com/akquinet/android-archetypes/wiki


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

  • Set up port forwarding as described here http://redkrieg.com/2010/10/11/adb-over-ssh-fun-with-port-forwards/ (this is where I am most fuzzy)
  • Build your maven android project using Right-Click / Clean and Build

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

 

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

Opinions expressed by DZone contributors are their own.

Related

  • Allow Users to Track Fitness Status in Your App
  • How to Build a React Native Chat App for Android
  • Simplifying Database Operations With HarperDB SDK for Java
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!