NDK-build does not stop on errors

The ndk-build.cmd script provided with Android NDK (checked on version r8) has a minor bug: when the build fails, the script still returns an exit code of 0 as if no problem has occurred.

To fix the bug, please open the <android-ndk-dir>\ndk-build.cmd file in a text editor that supports Unix line endings (such as Notepad++). The file will look like this:

@echo off
rem This is a Windows cmd.exe script used to invoke the NDK-specific GNU Make executable
set NDK_ROOT=%~dp0
set NDK_MAKE=%NDK_ROOT%/prebuilt/windows/bin/make.exe
%NDK_ROOT%\prebuilt\windows\bin\make.exe -f %NDK_ROOT%build/core/build-local.mk SHELL=cmd %* || exit /b %ERRORLEVEL%

Remove the ||exit /b %ERRORLEVEL% construct from the end of last line. The modified file will look as follows:

@echo off
rem This is a Windows cmd.exe script used to invoke the NDK-specific GNU Make executable
set NDK_ROOT=%~dp0
set NDK_MAKE=%NDK_ROOT%/prebuilt/windows/bin/make.exe
%NDK_ROOT%\prebuilt\windows\bin\make.exe -f %NDK_ROOT%build/core/build-local.mk SHELL=cmd %*

As the exit code of a batch file is the exit code of the last command in it, the modified file will work correctly. Please save the file and try building your project again.

You can also download a fixed ndk-build.cmd file here and replace the original file with it.