This document explains the
Application.mk build file used by
We recommend that you read the Concepts page before this one.
Application.mk specifies project-wide settings for ndk-build. By default,
it is located at
jni/Application.mk, in your application's project directory.
By default, the NDK build system generates code for all non-deprecated ABIs. You
can use the
APP_ABI setting to generate code for specific ABIs. Table 1 shows
APP_ABI settings for different instruction sets.
APP_ABI := armeabi-v7a
|64-bit ARMv8 (AArch64)
APP_ABI := arm64-v8a
APP_ABI := x86
APP_ABI := x86_64
|All supported ABIs (default)
APP_ABI := all
You can also specify multiple values by placing them on the same line, delimited by spaces. For example:
APP_ABI := armeabi-v7a arm64-v8a x86
For the list of all supported ABIs and details about their usage and limitations, refer to Android ABIs.
Flags to be passed to the assembler for every assembly source file (
.S files) in the project.
Flags to be passed to YASM when for all YASM source files (
By default, ndk-build assumes that the Android.mk file is located at
jni/Android.mk relative to the project root.
To load an Android.mk file from a different location, set
to the absolute path of the Android.mk file.
Flags to be passed for all C/C++ compiles in the project.
Set to true to enable clang-tidy for all modules in the project. Disabled by default.
Flags to pass for all clang-tidy executions in the project.
Flags to be passed for all C compiles in the project. These flags will not be used for C++ code.
Flags to be passed for all C++ compiles in the project. These flags will not be used for C code.
APP_CPPFLAGS, but will appear after
APP_CPPFLAGS in the compile
command. For example:
APP_CPPFLAGS := -DFOO
APP_CXXFLAGS := -DBAR
The above configuration will result in a compilation command similar to
-DFOO -DBAR rather than
clang++ -DBAR -DFOO.
Set to true to build a debuggable application.
Flags to be passed when linking executables and shared libraries.
Absolute path to an AndroidManifest.xml file.
$(APP_PROJECT_PATH)/AndroidManifest.xml) will be used if it
An explicit list of modules to build. The elements of this list are the names of
the modules as they appear in
LOCAL_MODULE within the Android.mk file.
By default, ndk-build will build all shared libraries, executables, and their
dependencies. Static libraries will be built only if they are used by the
project, the project contains only static libraries, or if they are named in
Define this optional variable as either
debug. Release binaries
will be built by default.
Release mode enables optimizations and may produce binaries that are not usable with a debugger. Debug mode disables optimizations so that debuggers may be used.
Note that you can debug either release or debug binaries. Release binaries, however, provide less information during debugging. For example, variables may be optimized out, preventing inspection. Also, code re-ordering can make it more difficult to step through the code; stack traces may not be reliable.
android:debuggable in your application manifest's
tag will cause this variable to default to
debug instead of
Override this default value by setting
APP_PLATFORM declares the Android API level this application is built against
and corresponds to the application's
If not specified, ndk-build will target the minimum API level supported by the NDK. The minimum API level supported by the latest NDK will always be low enough to support nearly all active devices.
For example, a value of
android-16 specifies that your library uses APIs that
are not available below Android 4.1 (API level 16) and can't be used on devices
running a lower platform version. For a complete list of platform names and
corresponding Android system images, see Android NDK native
When using Gradle and
externalNativeBuild, this parameter should not be set
directly. Instead, set the
minSdkVersion property in the
productFlavors blocks of your
build.gradle file. This
makes sure your library is used only by apps installed on devices running an
adequate version of Android.
Note that the NDK does not contain libraries for every API level of Android. Versions that did not include new native APIs are omitted to save space in the NDK. ndk-build uses, in descending order of preference:
- The platform version matching
- The next available API level below
APP_PLATFORM. For example,
android-19will be used when
android-20, since there were no new native APIs in android-20.
- The minimum API level supported by the NDK.
The absolute path of the project's root directory.
The project-wide equivalent of
LOCAL_SHORT_COMMANDS. For more information, see
the documentation for
LOCAL_SHORT_COMMANDS in Android.mk.
The C++ standard library to use for this application.
system STL is used by default. Other choices are
none. See NDK C++ Runtimes and
The argument to be passed to
strip for modules in this application. Defaults
--strip-unneeded. To avoid stripping all binaries in the module, set to
none. For other strip modes, see the strip
Set to true to use thin archives for all static libraries in the project. For
more information, see the documentation for
Path to the wrap.sh file to be included with this application.
A variant of this variable exists for each ABI, as does an ABI-generic variant: