Clone this repo:
  1. 972ddee Merge changes I64274b71,Id0f3933e,If5733458,Ie8614c9e,I6adbe857 by Treehugger Robot · 10 hours ago master
  2. a813f74 Clean up some redundant initialization. by Dan Albert · 34 hours ago
  3. 1036bee Re-raise worker exceptions in the calling process. by Dan Albert · 14 hours ago
  4. dd7bd8e Default WorkQueues to the number of CPUs. by Dan Albert · 35 hours ago
  5. a984a6f Add a DummyWorkQueue for debugging purposes. by Dan Albert · 22 hours ago

Android Native Development Kit (NDK)

The latest version of this document is available at

Note: This document is for developers of the NDK, not developers that use the NDK.

The NDK allows Android application developers to include native code in their Android application packages, compiled as JNI shared libraries.

Other Resources

This doc gives a high level overview of the NDK's build, packaging, and test process. For other use cases, or more in depth documentation, refer to the following sources:

Building the NDK

Both Linux and Windows host binaries are built on Linux machines. Windows host binaries are built via MinGW cross compiler. Systems without a working MinGW compiler can use build/tools/ to generate their own and be added to the PATH for build scripts to discover.

Building binaries for Mac OS X requires at least 10.8.

Target headers and binaries are built on Linux.


The NDK consists of three parts: host binaries, target prebuilts, and others (build system, docs, samples, tests).

Host Binaries

  • toolchains/ contains GCC and Clang toolchains.
    • $TOOLCHAIN/ contains ARCH and ABIS this toolchain can handle.
    • $TOOLCHAIN/ contains toolchain-specific default CFLAGS/LDFLAGS when this toolchain is used.
  • prebuilt/$HOST_TAG contains build dependencies and additional tools.
    • make, awk, python, yasm, and for Windows: cmp.exe and echo.exe
    • ndk-depends, ndk-stack and ndk-gdb can also be found here.

Target Headers and Binaries

  • platforms/android-$VERSION/arch-$ARCH_NAME/ contains headers and libraries for each API level.
    • The build system sets --sysroot to one of these directories based on user-specified APP_ABI and APP_PLATFORM.
  • sources/cxx-stl/$STL contains the headers and libraries for the various C++ STLs.
  • prebuilt/android-$ARCH/gdbserver contains gdbserver.


  • build/ contains the ndk-build system and scripts to rebuild NDK.
  • sources/android and sources/third_party contain modules that can be used in apps (cpufeatures, native_app_glue, etc) via $(call import-module, $MODULE)
  • tests/


  • AOSP NDK Repository

    • Check out the branch master-ndk

      repo init -u \
          -b master-ndk
      # Googlers, use
      repo init -u \
          persistent- \
          -b master-ndk
  • Additional Linux Dependencies (available from apt):

    • bison
    • flex
    • libtool
    • mingw-w64
    • zip
    • pbzip2 (optional, improves packaging times)
    • texinfo
    • asciidoctor
    • ruby-pygments.rb
    • python-nose
    • python3 (used for Vulkan validation layer generation)
    • python-lxml (used for Vulkan validation layer generation)
  • Mac OS X also requires Xcode.

  • Running tests requires that adb is in your PATH. This is provided as part of the Android SDK.

Building the NDK

For Linux or Darwin:

$ python

For Windows, from Linux:

$ python --system windows  # Or windows64. also accepts a variety of other options to speed up local builds, namely --arch and --module.


By default, will also package the NDK and run basic tests. To skip the packaging step, use the --no-package flag. Note that running the tests does require the packaging step.

If you need to re-run just the packaging step without going through a build, packaging is handled by build/tools/


Testing is discussed in