Starting Android NDK is easy!

Android NDK Develop environment set up summary

Usually Android application is developed by Java, but you can use C/C++ source code together with Android NDK (Android Native Development Kit). It provides us a opportunity to re-use/integrate existing C source code as well.

Below is summary for the steps how to start working with Android NDK.

Step1. Download installer from official site

Visit download site here, and choose installer depending on your development OS platform. In my case, I was working on Windows 7 64-bit OS, I chose android-ndk-r10e-windows-x86_64.exe.

Step2. Execute installer 

Double click to execute downloaded installer(.exe file in Windows case). It will just automatically extract the files to construct NDK working directory set. It takes a time, maybe ~ 10 min.

Step3. Move extracted folder to favorite place

After Step2, you get extracted directory, something like “android-ndk-r10e“. Move whole this directory to any favorite place.

(For example, I moved it to C:\Users\[myUserName]\AppData\Local\Android\android-ndk-r10e, since there was sdk folders in C:\Users\[myUserName]\AppData\Local\Android\sdk .)

Step4. Set environment PATH to point NDK folder path

Windows case: Go to [Control Panel] → [System and Security] → [System] → [Advanced system settings] → [Environment Variables]

In System variables category, find “Path” variable and press [Edit…] to add NDK folder path. In my case it is adding Variable value as,

The paths already written;C:\Users\[myUserName]\AppData\Local\Android\android-ndk-r10e

That’s all. Environment Path setting is necessary for executing “ndk-build” command, which is used to compile C/C++ source code for Android development. You can find ndk-build in C:\Users\[myUserName]\AppData\Local\Android\android-ndk-r10e\ndk-build.

I will write C:\Users\[myUserName]\AppData\Local\Android\android-ndk-r10e as $NDK_PATH.

Sample source code testing

NDK folder comes with many sample source codes so that you can easily find how to write C code and JNI. The sample source codes can be found in $NDK_PATH/samples.

Details are explained in Android developer ndk setup guides page.

More to do

Usually, we build .so file from C/C++ source code and use it as library. Instead, it is also possible to build executable file and execute directory inside Android device.

Leave a Comment

Your email address will not be published. Required fields are marked *