cd $PROJECT $NDK/ndk-buildWhere $NDK points to your NDK installation path. You can also create an alias or add $NDK to your PATH to avoid typing it every time.
ndk-build --> rebuild required machine code. ndk-build clean --> clean all generated binaries. ndk-build NDK_DEBUG=1 --> generate debuggable native code. ndk-build V=1 --> launch build, displaying build commands. ndk-build -B --> force a complete rebuild. ndk-build -B V=1 --> force a complete rebuild and display build commands. ndk-build NDK_LOG=1 --> display internal NDK log messages (used for debugging the NDK itself). ndk-build NDK_DEBUG=1 --> force a debuggable build (see below) ndk-build NDK_DEBUG=0 --> force a release build (see below) ndk-build NDK_APP_APPLICATION_MK=<file> --> rebuild, using a specific Application.mk pointed to by the NDK_APP_APPLICATION_MK command-line variable. ndk-build -C <project> --> build the native code for the project path located at <project>. Useful if you don't want to 'cd' to it in your terminal.
$NDK/ndk-build NDK_DEBUG=1 => forces the generation of debug binaries $NDK/ndk-build NDK_DEBUG=0 => forces the generation of release binariesIf you don't specify NDK_DEBUG, ndk-build will keep its default behaviour, which is to inspect the AndroidManifest.xml, if any, and see if its <application> element has android:debuggable="true".
IMPORTANT: If you use the build tools of SDK r8 (or higher), you won't need to touch your AndroidManifest.xml file at all! That's because if you build a debug package (e.g. with "ant debug" or the corresponding option of the ADT plugin), the tool will automatically pick the native debug files generated with NDK_DEBUG=1.Also, as a convenience, the release and debug object files generated by the NDK are now stored in different directories (e.g. obj/local/<abi>/objs and obj/local/<abi>/objs-debug). This avoids having to recompile all your sources when you switch between these two modes (even when you only modified one or two source files).
GNUMAKE=/usr/local/bin/gmake ndk-buildOr to make the change more permanent:
export GNUMAKE=/usr/local/bin/gmake ndk-buildAdapt to your shell and GNU Make 3.81 installation location.
$GNUMAKE -f $NDK/build/core/build-local.mk [parameters]Where '$GNUMAKE' points to GNU Make 3.81 or later, and $NDK points to your NDK installation directory. Use this knowledge if you want to invoke the NDK build script from other shell scripts (or even your own Makefiles).