I searched forever for a way to just build the examples in the Android NDK, preferably from the command line. Here's how.

First step: build the C++ code:

cd /usr/src/android-ndk-r6/samples/san-angeles/

Simple enough.

Second step:

You will then need to generate your final .apk through the usual means. -- Android NDK Dev Guide

Thanks a ****ing lot!

In addition the documentation is very much Eclipse-centered - and I can't be bothered to install and configure all the Eclipse stack for a mere Java wrapper for the above-generated .so file XD

We first need to use the 'android' wrapper and download the "SDK Platform Android 2.2, API 8, revision 3" - aka "android-8", the first environment to support OpenGL ES 2.


It appears we first need to "manage the project", more precisely import from an existing project:


So we create a project by importing the sources from the current directory:

/usr/src/android-sdk-linux_x86/tools/android update project \
  --name san-angeles --path . --target "android-8"

Then we use ant to build the thing:


apt-get install ant openjdk-6-jdk
ant debug  # avoid messing with signing

We now have a bin/san-angeles-debug.apk and we can run it in the emulator. Create a new "Virtual device" using the "android-8" platform we downloaded above, and launch it. Given the time needed to boot the OS, I suggest enabling snapshots. Scaling to display resulted in a very tiny, dark and slow display, in a first step I suggest using a non-scaled one.


At last we can run it! Install it in the emulator:

/usr/src/android-sdk-linux_x86/platform-tools/adb install -r bin/san-angeles-debug.apk

You'll find a DemoActivity in your apps directory :)

Note: I tried to compile the "hello-gl2", showcasing OpenGL ES 2.0, but sadly it crashes:

Sorry! The application GL2JNI (process com.android.gl2jni) has stopped unexpectedly. Please try again.

The emulator apparently doesn't advertise EGL_OPENGL_ES2_BIT (checked in in GL2JNIView.java). If you try to by-pass it, you'll get loads of:

E/libEGL ( 333): called unimplemented OpenGL ES API

It's worth noting the OpenGLES20 sample from the "API Demos" application uses a fall-back OpenGL ES 1 renderer if v2 is not available - it made me mistakenly believe that OpenGL ES 2 was supported only from Java >(

OpenGL ES 2 is not supported in the emulator as of 2011-09-17 - period.


Is there any team in Debian related with Android? I just know about the pkg-fso team but is not related with Android, do you believe an Android team in Debian would it be useful?

Best Regards,

Fernando C. Estrada

Comment by Anonymous Sun Sep 18 07:33:59 2011

I don't know about a Debian Android team, but it would definitely be useful to package Android for Debian and get a guaranteed 100%-free packages for Debian main. Do you know people that would be interested?

There is some activity wrt installing Debian instead of (or alongside) Android on small devices, but that's another matter.

Comment by beuc Sun Sep 18 11:55:37 2011
Thank you! It works fine also on Slackware x86_64 after installing a package named 'ant-apache'.
Comment by Anonymous Mon Jul 2 19:08:37 2012
Worked like a miracle!
Comment by Anonymous Thu Dec 6 11:00:00 2012