O'Reilly logo

Programming Android by Zigurd Mednieks, G. Blake Meike, Masumi Nakamura, Laird Dornin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Android NDK

The Android Native Development Kit (NDK) is a companion tool to the Android SDK. If you use the NDK to create native code, your applications are still packaged into an .apk file and run inside a VM on the device. The fundamental Android application model does not change.

Setting Up the NDK Environment

In order to use the NDK, you must first install and set up the SDK. The system requirements for installing and using the NDK are as follows:

  • Windows XP (32-bit) or Vista (32- or 64-bit) with Cygwin 1.7 or later

  • Mac OS X 10.4.8 or later

  • Linux (32- or 64-bit)

Necessary development tools that are not provided in the NDK are as follows:

  • GNU Make 3.81 or later

  • A recent version of Awk (either GNU Awk or Nawk)

First, download and install the NDK (http://developer.android.com/sdk/ndk/index.html). Installation is simple: unzip the NDK into any directory. Here, we will refer to that directory as ndk.

Once the NDK is downloaded and installed, you will find quite a bit of documentation (located in the ndk/docs directory). We highly recommend that you read the documentation, starting with OVERVIEW.html. Also included in the NDK are samples (located in ndk/samples). The samples cover quite a bit more than this chapter will, so after you have used the NDK a bit, we recommend that you go through the samples.

Compiling with the NDK

In order to develop native code with the NDK, you will need to do the following:

  1. Create a jni directory within your project.

  2. Place your native source in the jni directory. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required