This recipe describes how to set up an Android NDK development environment in Mac OS.
Android development requires Mac OS X 10.5.8 or higher, and it works on the x86 architecture only. Ensure that your machine meets these requirements before getting started.
Register an Apple developer account, then go to https://developer.apple.com/xcode/ to download Xcode, which contains a lot of developer tools, including the make
utility required for Android NDK development. After the download is complete, run the installation package and make sure that the
UNIX Development option is selected for installation.
As usual, Java JDK 6 or above is required. Mac OS X usually ships with a full JDK. We can verify that your machine has the required version by using the following command:
$javac -version
Setting up an Android NDK development environment on Mac OS X is similar to setting it up on Ubuntu Linux. The following steps explain how we can do this:
~/.profile
. If the file doesn't exist, create a new one. Save the changes and log out of the current session:export ANDROID_SDK=<path to Android SDK directory> export PATH=$PATH:$ ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
tools
directory by typing the command android
. Select Android SDK Tools, Android SDK Platform-tools, at least one Android platform (the latest one is preferred), System Image, SDK Samples, and Android Support. Then click on Install. In the next window, read and accept all the license agreements, then click on Install.~/.profile
in step 3:export ANDROID_SDK=<path to Android SDK directory> export ANDROID_NDK=<path to Android NDK directory> export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK
samples/hello-jni
directory in NDK. Type the command ndk-build
. If the build is successful, it proves that the NDK environment is set up correctly.