1. Download NDK, address: http://developer.android.com/tools/sdk/ndk/index.html
2. Unzip, the unzipped folder can be moved to other folders, and then add its path to the environment variable.
3. Open terminal in Launchpad
4. Enter vim ~/.bash_profile and press Enter
5. Press the English key i to enter the editing mode, and add export PATH=${PATH}: your NDK path in it
quote
For example, I put the NDK in the adt-bundle-mac-x86_64 folder of the application, so enter:
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64/android-ndk-r8e
6. Press the esc key to exit the editing mode, enter: wq (colon key + English key w + English key q), press Enter.
quote
:w means save
:q means quit
:wq means save and exit
7. Type source ~/.bash_profile and press Enter for the previous changes to take effect.
Done, you can now use the ndk-build command directly.