Android Native Development on Ubuntu 9.04 (Jaunty Jackalope)
Get all 5 posts on
Android development in
a downloadable PDF.
Part Three of a Series of Posts about Android Mobile Application Development.
In prior blog posts, Developing An Android Mobile Application and Android Software Development Tools – What Do I Need?, I discussed our approach for choosing Android as the next platform for our company’s mobile application, Aton Connect, which runs successfully on Windows Mobile phones and devices. Once we identified which platform, we needed to decide on development tools that would allow us to get started on developing our mobile application rapidly.
Aton International has been developing for Windows Mobile since 2001. So, at first, our approach to Android followed the the same steps that we would take to develop an application for Windows Mobile. But, there are some significant differences between the two platforms. I have mentioned our false starts in these articles so that you don’t have to waste time going down those same paths.
The Bottom Line: A Linux Installation
Because we want to leverage an existing Windows XP workstation, we elected to install Ubuntu Linux in a virtual machine running on Windows XP. There are several vendors of VM software for Windows. Being economy minded, we passed on VMware, which requires a paid commercial software license. Microsoft Virtual PC is currently in transition. Virtual PC 2007 is still available for free download and will run on Windows XP, but it does not support Linux well, nor will it support USB devices. A newer version of Virtual PC is in beta. It requires a Windows 7 host, CPU virtualization hardware, and does not list any support for Linux.
Instead, we chose the open source tool , VirtualBox, from Sun Microsystems as a virtual machine platform. It runs on a broad range of x86 hardware and OS configurations, and supports Linux, Windows, and many other OS types. It has built in USB support, and will work with or without CPU virtualization hardware.
If you do have an x86 CPU with virtualization hardware, then you can run 64 bit guest operating systems on your 32 bit Windows XP host. Virtual Box can be obtained from http://www.virtualbox.org/wiki/Downloads. The version for Windows hosts – x86/amd64, is an EXE file containing a Windows Installer file. Simply download and execute the EXE file. It will install several unsigned drivers, requiring you to choose the “Continue Anyway” option several times to complete the installation.
There are a myriad of Linux distributions available. We settled on Ubuntu 9.04 because it seems to be the most comprehensive and easiest to install with a large complement of supported drivers. Also, the Android SDK indicates it has been tested on an earlier version of Ubuntu. You can download an ISO file containing the Ubuntu 9.04 image from http://www.ubuntu.com/getubuntu/download. The image size is close to 700 MB and may not record accurately on some CD media due to overrun. If you want to you can record it to DVD media, although it is easy to use the ISO file directly with VirtualBox, no DVD media is required.
Installing Ubuntu on VirtualBox is straightforward. Select the “New” button and give your machine a name like “Android”. Choose Linux as the Operating System Type, note that the first version listed is Ubuntu. The default base memory size of 384 MB is adequate for our purposes. On the next pane of the new machine wizard, you can generate a new virtual hard drive. Choose the default “Dynamically Expanding” storage type, but on the next pane, increase the default from 8 GB to something like 200 GB. The drive will only use actual disk space to contain files stored on the virtual hard drive. If you leave the size as the default 8 GB and you run out of space, there is no easy way to increase the limit. It is much easier to set the maximum drive size to a large value at the time the drive is defined. The dynamically expanding drive will only use as much physical hard drive space as needed to store the files stored on the virtual hard drive.
Once you have completed the new machine wizard, you need to make some settings adjustments using the Settings button. Choose the Advanced tab on the General Settings and turn on the “Enable PAE/NX” checkbox. Ubuntu may not boot if this setting is off. You can also turn off the “Floppy” selection in the Boot Order. To view the Linux file system from Windows XP choose “Bridged Adapter” as a network attachment method. You can enable audio from Linux with Windows DirectSound and ICH AC97 as the audio controller.
Finally, you need to connect the virtual CD drive to the Ubuntu ISO file you downloaded, by selecting the CD/DVD ROM settings, enabling the “Mount CD/DVD Drive” checkbox, selecting the “ISO Image File” radio button, then browsing to the “ubuntu-9.04-desktop-i386.iso” file we downloaded previously. With this ISO file selected, VirtualBox will boot into the Ubuntu image when the Android virtual machine is started.
After starting your Android VM, the Ubuntu startup screen will appear where you can use the keyboard to select your language, and the Install Ubuntu selection. After a short time, a GUI installer will appear and you can use your mouse to choose the default selections. Once you click your mouse inside the VM window, you will need to click the right control key to move it back to other Windows XP windows. This will be true until you install the “Guest Additions” after Ubuntu is installed. You will need to use the Right Ctrl key to extract the mouse pointer from dark Ubuntu screen and dismount the ISO image from the virtual CD drive when asked to do so by the installation program.
Installing the VirtualBox Guest Additions
Once Ubuntu is installed you can install the “Guest Additions”. The guest additions are some drivers and applications installed in the guest operating system (Ubuntu) that communicate with the host operating system (Windows XP). Installing the guest additions will allow the mouse to travel seamlessly between the Ubuntu window and the rest of Windows XP windows. It also enhances the video display in Ubuntu allowing for automatic resizing when the guest window size is changed in Windows XP.
To install the guest additions, extract the mouse pointer and select “Install Guest Additions” from the Devices menu. This will connect an ISO file containing the guest additions to the Ubuntu CD device and the CD file system icon will appear on the Ubuntu desktop. Instead of a single click install as would happen in Windows, you need to open a terminal window from the Applications | Accessories menu. Once the terminal window opens, enter these two command lines: “cd /media/cdrom” followed by “sudo ./VBoxLinuxAdditions-x86.run”. You will be asked for your administrator password and a command line script will run. After this script completes, you will need to restart Ubuntu. Once Ubuntu has restarted, the guest additions have been installed and you can unmount the guest additions ISO file from the CD device.
If you are connected to the Internet, you can install updates. To access the internet you may need to activate the network connection using the icon on the top menu bar to select the “Auto eth0” mode. If you have not been already prompted to install updates, you can use the “System | Administration | Update Manager” menu item to start the update process.
Make Your Ubuntu File System Visible to Windows
You can make the Ubuntu file system visible to your Windows XP machine via Samba if you chose “Bridged Adapter” as a network attachment in the VirtualBox machine settings. To install Samba, use the Ubuntu “Applications | Add / Remove” and search “All Open Source applications” for “Samba”. This search will locate the “Samba” and several others related to Samba. Selecting the one item simple titled “Samba”. When you apply this setting, several Samba related packages will be loaded.
To configure Samba, use the “System | Administration | Samba” menu item to bring up the “Samba Server Configuration” dialog screen. The printer share is added by default. To share files, click the “Add Share” button. In the Basic tab, enter a directory path to share, or simply “/” if you want to share the entire file system. The value “/root” is not valid for Ubuntu. Give the share a name meaningful to you and select the Writable and Visible checkboxes as appropriate for your purposes. In the Access tab, select the “Allow access to everyone”, as the Ubuntu user names are not meaningful to Windows.
Next, select the “Preferences | Server Settings” menu item. For the workgroup name, you enter a Windows Domain name (single word) if you are in a Windows Domain environment. Otherwise the workgroup name is set to the Windows Workgroup name. The Description field can be left to its default value “%h server (Samba, Ubuntu)”. On the Security tab, you can use the default settings: Authentication Mode: User, Authentication Server: *, Kerberos Realm: , Encrypt Passwords: Yes, Guest Account: No guest account.
After setting up Samba, reboot Ubuntu, and you can access your Ubuntu file system from Windows as a shared drive. Note that all folders can be read using the settings given here, but only Ubuntu folders such as /tmp that have appropriate permissions can be written into.
Installing Java JDK and Eclipse Tools
The Eclipse IDE runs on Java, so the next step is to install Java and then Eclipse. There are many ways to accomplish this, we describe one of the simpler ways here.
To install Java 6 Runtime, use the Ubuntu “Applications | Add / Remove” and search “All Open Source applications” for “Java”. This search will locate the “OpenJDK Java 6 Runtime”. Selecting this item may also co-install the “OpenJDK Java 6 Web Start”.
To complete the Java 6 installation in Ubuntu, go to the web page at: http://www.java.com/en/download/installed.jsp and click on the “Verify Java Version” button. This will bring up a message bar in Firefox labeled “Additional Plugins are required to display all the media on this page”. Click the “Install missing plugins” button on this bar which will bring up the Plugin Finder Service screen. Choose the “The Java Plug-in, Java SE 6” which will install sun-java6-plugin.
Although it would be nice to be able to install Eclipse from the Add/Remove Programs or Synaptics Package Manager, the version of Eclipse available here is the older 3.2 version. We want to use the current version, now 3.4.2. So download the latest Eclipse version from: http://www.eclipse.org/downloads. Choose the “Eclipse IDE for Java Developers – Linux 32bit” version. Download this archive file into your Ubuntu home directory: $HOME. Then open up a file browser using the “Places | Home Folder” main menu item. In the file browser window you will see the Eclipse archive download you just made, with a file name like “eclipse-java-ganymede-SR2-linux-gtk.tar.gz”. Right click this file in the file browser and select “Extract Here”.
This will unpack Eclipse into a directory tree named “eclipse” in your home directory. You can then start up Eclipse by using the file browser to view the folder named eclipse in your home directory ($HOME/eclipse), then double clicking the application named “eclipse”. After you accept the default or specify another workspace location, the Eclipse IDE comes into view. You can use the menu item “Help | About Eclipse” item to verify the installed version of Eclipse, which is currently 3.4.2. At this point you have verified that you have installed both Java 6 and Eclipse. You can also create a desktop launcher for Eclipse that points to $HOME/eclipse/eclipse.
Installing the Android SDK
The next step is to install the Android SDK, located here: http://developer.android.com. Download the Linux version ZIP file archive into your home directory $HOME. Then open up a file browser using the “Places | Home Folder” main menu item. In the file browser window you will see the Android SDK archive download you just made, with a file name like “android-sdk-linux_x86-1.5_r2.zip”. Right click this file in the file browser and select “Extract Here”. This will unpack the Android SDK into a directory tree named “android-sdk-linux_x86-1.5_r2” in your home directory. Further details on installing the SDK and ADT are located at the link: http://developer.android.com/sdk/1.5_r2/installing.html.
Installing the ADT plug-in into Eclipse
Next you can install the Android Development Tool or ADT plug-in into Eclipse. This plug-in is what turns Eclipse into a powerful tool for Android Java development. The instructions to do this are also located at the link: http://developer.android.com/sdk/1.5_r2/installing.html.
To verify your installation of Eclipse, Android SDK, ADT, and Java, you can build a sample “Hello World” application using the instructions located here: http://developer.android.com/guide/tutorials/hello-world.html. Set a breakpoint in the Java source code and start the program in Eclipse debug mode. You can see the emulator startup, and stop execution at the breakpoint you set. You can single step the Java code or let it run freely to display the “Hello World” message on the Android emulator screen.
If you are only developing Java applications for Android, you now have a complete set up development tools. But if your goal includes C/C++ native code, there is more work to do. The tools you need for native code Android development are included with the Android open source project, so the next task is to download that.
The details for getting and building the Android source are at this link: http://source.android.com/download. Following the instructions on that page will get you the tools and headers necessary to build C/C++ native applications and libraries that can be shared to be accessed by Java code.
In our next installment, we will offer details and examples for Android C/C++ native code development and debugging of native code.
* * * * * * * *
Get all 5 posts on android development in a downloadable PDF.
With 20+ years as a top software and firmware developer, Charles Wilde has acquired a combination of proven business smarts, mobile development skills and device engineering expertise that is hard to match. Charles is available to consult with you and your team about native code development in Android, Windows Mobile or Windows CE. Just email him at AtonMail@aton.com.
Related posts
- Android Software Development Tools - What Do I Need?
- Pure Native App or Java Shell for Android Market?
- Android Native Development Using the Android Open Source Project
- Android Native Libraries for Java Applications
- Developing An Android Mobile Application
1 Comment
Sorry, the comment form is closed at this time.

Thanks for sharing your experiences! This is extremely valuable to me as I’m just starting the learning process on this same topic. Well written and fantastic links/references!
Again, thanks!