Android NDK (OSX)

The Android Native Development Kit allows you to use C or C++ libraries in your Android Applications. I had to use it to build the official Android Telegram App, which uses this approach to include some libraries.

Install

  1. Download NDK and extract it (see instructions)
  2. Move it to some folder. eg:
    mv android-ndk-r10e /usr/local/android-ndk
  3. Add the path to your .profile file. I am a zsh-user so I used the following command to update my settings and load them:
    echo -e "export NDK=/usr/local/android-ndk\nexport PATH=$PATH:$NDK" >> ~/.zprofile
    source ~/.zprofile

Example Usage

ndk-build NDK_PROJECT_PATH=~/Documents/dipl/Telegram/TMessagesProj/jni APP_PROJECT_PATH=~/Documents/dipl/Telegram/TMessagesProj

Use ndk-build clean to remove all already-compiled binaries.

Tips

  • Take a look at your Application.mk. Variables (e.g. APP_PLATFORM) should be defined within this file.
  • Install it to your home folder (e.g. ~/android-ndk-r10e). This will help some tools to find the ndk automatically.

Links