The Android NDK comes with several examples. This guide assumes you have the NDK environment setup as described here:

When you extract the NDK, you will see a samples folder.

There’s no Eclipse project file in these samples, but it’s very easy to create them.

1. Do File->New->New Project->Android->Android Project.

2. Select Create Project From Existing Location. A dialog will pop up.

3. Browse to one of the subfolders inside samples. Below, I selected the samples/native-plasma folder.

Most of the fields should be filled automatically. You might want to select API level 9 or above to be safe. Make sure you have an ADV or a real device that supports the API level. (See here for AVD help).

Click Finish.

4. Right click on the project name on the Eclipse (or bring up its context menu), then select Android Tools -> Add Native Support (remember you must have the Sequoyah plug-in for this). A dialog will pop-up, leave the default (but if the NDK path is wrong, set it to the correct path).

5. You can now build the project, using Project->Build Project. Pay attention to the Console (Window -> Show View ->Console), which should output the compilation progress, like this:

**** Build of configuration Default for project NativeActivity ****

bash C:\android-ndk-r5c\ndk-build V=1 
cygwin warning:
  MS-DOS style path detected: C:\PERMADI_WORKSPACE\ndkFresh\android-ndk-r5c\samples\native-plasma
  Preferred POSIX equivalent is: /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:

rm -f /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/libs/armeabi/lib*.so /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/libs/armeabi-v7a/lib*.so /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/libs/x86/lib*.so

<em>BLA... BLA...</em>

install -p /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/obj/local/armeabi-v7a/ /cygdrive/c/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/libs/armeabi-v7a/
/cygdrive/c/android-ndk-r5c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded C:/PERMADI_WORKSPACE/ndkFresh/android-ndk-r5c/samples/native-plasma/libs/armeabi-v7a/

**** Build Finished ****

Note: Errors are highlighted in RED background in Eclipse. Even though you may see Build Finished, you need to make sure there really is no error before continuing.

6. Run it (Run->Run As). Select Android Application.

Here’s the result of NativePlasma sample, running on the emulator.

One Response to “Running Android NDK Examples Using Eclipse and Sequoyah”

  1. [...] Running Android NDK Examples Using Eclipse and Sequoyah [...]

Leave a Reply