The NDK allows Android application developers to include native code in their Android application packages, compiled as JNI shared libraries.
See the Getting Started Guide for an introduction.
See the changelist for a list of changes since the previous release.
Finally, discussions related to the Android NDK happen on the android-ndk Google Group.
Note: This document is for developers of the NDK, not developers that use 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/build-mingw64-toolchain.sh 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).
toolchains/contains GCC, Clang, and Renderscript toolchains.
$TOOLCHAIN/config.mkcontains ARCH and ABIS this toolchain can handle.
$TOOLCHAIN/setup.mkcontains toolchain-specific default CFLAGS/LDFLAGS when this toolchain is used.
prebuilt/$HOST_ARCH/contains various tools to make the build system hermetic.
ndk-stackshould probably go in
prebuilt/to avoid collisions between host variants.
platforms/android-N/arch-$ARCH_NAME/contains headers and libraries for each API level.
--sysrootto one of these directories based on user-specified
sources/cxx-stl/$STL/$ABI/contains the headers and libraries for the various C++ STLs.
build/contains the ndk-build system and scripts to rebuild NDK.
sources/contains modules useful in samples and apps via
$(call import-module, $MODULE)
```bash repo init -u https://android.googlesource.com/platform/manifest \ -b master-ndk # Googlers, use repo init -u \ persistent-https://android.git.corp.google.com/platform/manifest \ -b master-ndk ```
Additional Linux Dependencies (available from apt):
$ python checkbuild.py --no-package
$ python checkbuild.py --system windows
The simplest way to package an NDK on Linux is to just omit the
--no-package flag when running
checkbuild.py. This will take a little longer though, so it may not be desired for day to day development.
To package the NDK for Windows or Darwin (or if more control over the packaging process is needed), invoke
build/tools/package-release.sh directly. This process will be improved in a future commit.
Running the NDK tests requires a complete NDK package (see previous steps). The full test suite includes tests which run on a device or emulator, so you’ll need to have adb in your path and
ANDROID_SERIAL set if more than one device/emulator is connected. With that package:
$ tar xf android-ndk-$BUILD_NUM-$HOST_TAG.tar.bz2 $ cd android-ndk-$BUILD_NUM $ export NDK=`pwd` $ python tests/run-all.py --abi $ABI_TO_TEST