To properly setup an environment for Android development using OpenSceneGraph, we need the following hardware and software:

  • Android Tablet – Acer Iconia Tab A510 (Tegra 3 Processor)
  • OpenSceneGraph – 3.0.1
  • cmake: 2.8+
  • g++
  • Eclipse Indigo
  • Ubuntu 11.04 or Ubuntu 11.10
  • Android SDK
  • Android NDK

Setup a working Android development environment in Ubuntu:

Open Synaptic Package Manager.

Install package openjdk-6-jdk.

Install the following two packages using either Synaptic or apt-get:

cmake (sudo apt-get install cmake)


Download Eclipse and extract it.

Download Android SDK and extract it into


Install ADT-Plugin into Eclipse.

Start Eclipse -> Help -> Install New Software -> in the field ‘Work with:’, fill in “”, then press Enter -> check “Developer Tools” -> press Next till everything is installed.

After restarting Eclipse: Window -> Android SDK Manager. Install AT Least Android 2.2 (API 8).(I installed ALL the Android API versions from API 8 to API 15). I installed these APIs to


Extract Android NDK to


(ndk-r7b and ndk-r7b have been proven to work with OSG)

After everything has been copied to the appropriate directories, we now have a working environment for Android development.

Installing OpenSceneGraph 3.0.1 for Android with OpenGE ES 1.x

Download OpenSceneGraph-3.0.1 (link) and extract it to


Download the 3rd party dependencies (link) and extract it to


Add environment variables so that cmake will find the right dependencies, open ~/.bashrc and add the following lines at the end of the file and save it:

export ANDROID_NDK=$HOME/Android/android-ndk-r7b 
export ANDROID_SDK=$HOME/android-sdks

Create two folders:



Open a terminal and change directory to


Type in or copy the following command in the terminal and press Enter (the flag -DJ=4 is to specify we have a quad-core processor):


After that, we build it (this step usually takes quite a while):


Install libraries and headers into $HOME/Android/OpenSceneGraph-3.0.1/osginstall into the folder obj, lib, and include, by typing:

make install

After this, we have a working environment for developing Android application using OpenSceneGraph.

An Example: creating and build a project

Copy the folder osgAndroidExampleGLES1 from


to your Eclipse workspace


Copy the three folders under $HOME/Android/OpenSceneGraph-3.0.1/osginstall, obj, lib, and include to your project folder:


Start Eclipse -> New -> Project -> Android Project, choose “Create project from existing source” and set the location to $HOME/workspace/osgAndroidExampleGLES1 -> Project Name is “osgAndroidExampleGLES1”, then Next -> build target should be Android 2.2 (API 8) or higher.

In Eclipse project browser, expand the folder jni and open in text editor, make the following two changes and save it:

Change line 7 to:
OSG_ANDROID_DIR := /home/USER/workspace/osgAndroidExampleGLES1
Change line 21 to:
LOCAL_DLIBS := -llog -lGLESv1_CM -ldl -lz -lgnustl_static
Open a terminal, and change directory to
$ANDROID_SDK/tools/android list targets
look for “android-8”, it’s the device with id: 7 under my setup, and you should change it according to your output.



Now the native code has been built for the Android OSG Viewer, we can go back to Eclipse and build the project from there.

A video demonstrating the osgViewer application on the Acer tablet.

* this tutorial was adapted from this link.