Monday, February 14, 2011

Meeting the natives

Of course I want to tinker with Android to the fullest, so we install the Native Development Kit (NDK).

After downloading the appropriate NDK from Google, simply uncompress it into a suitable directory.
$ bunzip2 ~/Downloads/android-ndk-r5b-linux-x86.tar.bz2
$ tar xvf ~/Downloads/android-ndk-r5b-linux-x86.tar ./
Now the NDK is located is some directory /android-ndk-r5b/.

...and that's it! Now time to have some fun.


NDK Examples

First review the examples included with the NDK. The basic flow (as described by the NDK page):


  1. Place your native sources under <project>/jni/...
  2. Create <project>/jni/Android.mk to describe your native sources to the NDK build system
  3. Optional: Create <project>/jni/Application.mk.
  4. Build your native code by running the 'ndk-build' script from your project's directory. It is located in the top-level NDK directory:
    cd <project>
    <ndk>/ndk-build
    
    The build tools copy the stripped, shared libraries needed by your application to the proper location in the application's project directory.
  5. Finally, compile your application using the SDK tools in the usual way. The SDK build tools will package the shared libraries in the application's deployable .apk file.
For complete information on all of the steps listed above, please see the documentation included with the NDK package.

No comments:

Post a Comment