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

Building the NDK

Both Linux and Windows NDKs are built on Linux machines. Windows host binaries are cross-compiled with MinGW.

Building the NDK for Mac OS X requires at least 10.8.


The NDK components can be loosely grouped into host toolchains, target prebuilts, build systems, and support libraries.

Host Toolchains

  • 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, python, yasm, and for Windows: cmp.exe and echo.exe
    • ndk-depends, ndk-stack and ndk-gdb can also be found here.

Target Prebuilts

  • sysroot/usr/include contains the headers for the NDK. See Unified Headers for more information.
  • platforms/android-$VERSION/arch-$ARCH_NAME/ contains stub shared libraries and a few static libraries for each API level. See Platform APIs for more information.
  • sources/cxx-stl/$STL contains the headers and libraries for the various C++ STLs.
  • prebuilt/android-$ARCH/gdbserver contains gdbserver.

Build Systems

  • build/ contains ndk-build, the NDK's home grown build system. Most of the implementation lives in build/core.
  • build/cmake contains components for using the NDK with CMake (at present only a CMake toolchain file, but in the future it will contain CMake modules that CMake will load, obviating the need for a toolchain file).
  • build/tools contains, but also contains legacy sripts that were used to build the NDK. Eventually, this should contain nothing but the standalone toolchain scripts.
  • The gradle plugins for the NDK are not included in the NDK.

Support Libraries

  • sources/android and sources/third_party contain modules that can be used in apps (gtest, cpufeatures, native_app_glue, etc) via $(call import-module,$MODULE).


  • 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):

    • asciidoctor
    • bison
    • dos2unix
    • flex
    • libtool
    • mingw-w64
    • pbzip2 (optional, improves packaging times)
    • python-lxml (used for Vulkan validation layer generation)
    • python-nose
    • python3 (used for Vulkan validation layer generation)
    • ruby-pygments.rb
    • texinfo
    • zip
  • 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. will also build all of the NDK tests. This takes about four times as long as building the NDK itself, so pass --no-build-tests to skip building the tests. They can be built later with python --rebuild. also accepts a variety of other options to speed up local builds, namely --arch and --module.


By default, will also package the NDK. To skip the packaging step, use the --no-package flag. To avoid packaging an incomplete NDK, packaging will not be run if --module was passed unless --force-package was also provided.