Android Native Development Kit

When you developing android application you will mostly write java or kotlin code, but did you know that we can write c or c++ code on our android application project using NDK or Native Development Kit.

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input. The NDK may not be appropriate for most novice Android programmers who need to use only Java code and framework APIs to develop their apps.

Source

So, when we need to use NDK? if we need to create a function or code that primarily processor-dependant such as computationally intensive app like games. Then what's the different between c/c++ and java/kotlin, any java/kotlin code that you write will be compiled to JVM/Dalvik bytecode in contrast c/c++ code compiles directly into native executable code for specific hardware architectures.

If you want to have better obfuscation of your code, you also need to consider NDK for a sensitive feature, why? Didn’t android already had obfuscation with R8? correct, but the result of the obfuscation still in a form of bytecode, compared to c/c++ obfuscation that already compiled into native executable.

In Conclusion, NDK only suitable on very specific cases that most of us never face it, even on the official android NDK outlined that NDK not suitable for most of the android programmers, but at least we now have an option when we face a rare case or specific case that really need benefits from the NDK.

Sources

https://developer.android.com/ndk/guides/concepts

https://www.geeksforgeeks.org/what-is-ndk-in-android/

https://www.techyourchance.com/android-ndk-tutorial/