Beginning android NDK in Ubuntu 10.04 – 12.04

I will describe here the basic steps to start playing with the NDK. This is only an introduction.

the NDK (Native development tool-kit) will allow you to integrate your C/C++ code in your Android apps. I will not discuss here when and and why it is better to use Java code instead of native code, that’s up to you and depends on each project.

You must have your development environment set up, if not you can find instructions here.

Download the NDK from

Once downloaded extract it wherever it is most suitable for you for example in the home folder.

Add the NDK folder to PATH:

in the terminal
cd android-ndk-rb8  (folder name may vary)

echo "export PATH=$(pwd):\${PATH}" >> ~/.bashrc

Now I have found using the command line tools easier than eclipse. Here is how you can try the first sample:


cd ADROID_NDK/samples/hello-jini

android update project -p .

ndk-build (build native code)

ant debug install (install on device or emulator so you must have one of them available)

now you can either search for the app icon on the device or do the following:

adb shell

  1. am start -a android.intent.action.MAIN -n

You will see there are other samples in the folder that can help you to understand how the NDK works