How to Get the Native Development Kit (NDK) to Develop Android Apps - dummies

How to Get the Native Development Kit (NDK) to Develop Android Apps

By Barry Burd

The creators of Android realized that developers would want to use non-Java code. So Android has a framework that mediates between Java and other languages. As you might have guessed, that framework is NDK — Android’s Native Development Kit. With Android’s NDK, you can write code that executes directly on a mobile device’s processor without relying on a virtual machine to carry out the instructions.

The NDK doesn’t come as part of Android’s standard Software Development Kit — its SDK. In fact, you don’t get the NDK by checking for available packages in the Android SDK Manager. The NDK is a separate archive file, available for download at Android’s Developer site.

On Windows, the NDK download is usually an .exe file. For Mac or Linux, the NDK download is usually a .bin file. The downloaded file is a self-extracting archive file. When you execute the file, your development computer extracts all the files stored in the archive.

To be more precise, the computer creates a new subdirectory of the directory containing the downloaded file. If you execute android-ndk-r10d.exe while it’s in your xyz directory, you get a new xyz/android-ndk-r10d directory. So your first step is to move the downloaded file to a place where you want your new android-ndk- whatever directory to live. It hardly matters where you move the file, as long as you remember where you move it.

The NDK files don’t like to be inside folders with blank spaces in their names. For example, in Windows, don’t move your android-ndk- whatever .exe file to the C:Program Files directory, or to any subdirectory of the C:Program Files directory.

The way you expand the NDK download’s contents depends on your development computer’s operating system.

On Windows, double-click the android-ndk- whatever .exe file’s icon.

On Linux or on a Mac, do the following:

  1. Click the Terminal button at the bottom of Android Studio’s main window.

    A Terminal window opens in the lower portion of Android Studio’s main window.

  2. In the Terminal window, use the Change Directory command (cd) to navigate to the directory containing the downloaded NDK archive.

    For example, if you moved the downloaded file to the /Users/JaneQReader directory, type

    cd /Users/JaneQReader
  3. Type the command ls ndk* and look for the name of the downloaded NDK archive. (It’s probably android-ndk-r10c-darwin-x86_64.bin, or something like that.)

  4. Assuming that the downloaded file’s name is android-ndk-r10c-darwin-x86_64.bin, type the following two commands:

chmod a+x android-ndk-r10c-darwin-x86_64.bin

When you follow these steps, your computer creates an android-ndk- something-or-other directory and puts a few files and subfolders into the directory. “A few files and folders,” is approximately 50,000 files in more than 4,000 folders. The extracted files consume more than three gigabytes of space.

Make note of the folder containing your extracted NDK materials.