When I was learning about Android development, I always heard someone mention NDK. What exactly is NDK?
I checked on the Internet and provided the following instructions:
NDK stands for Native Development Kit.
1. NDK is a collection of tools. * NDK provides a series of tools to help developers quickly develop C (or C ++) dynamic libraries and automatically package so and java applications into apk. These tools are of great help to developers. * NDK integrates with the cross compiler and provides the corresponding mk file isolation platform, CPU, API, and other differences, developers can create so simply by modifying the mk file (indicating "which files need to be compiled" and "Compilation feature requirements. * NDK can automatically package so and Java applications, greatly reducing developers' packaging work.
2. NDK provides a stable and functional API header file statement. Google explicitly states that this API is stable and supports the currently released API in all subsequent versions. From the NDK version, we can see that these Apis support very limited functions, including: C standard library (libc), standard Math Library (libm), and compression library (libz), Log Library (liblog ).
That is to say, Android supports C and C ++ development. But it doesn't mean that with NDK, we can abandon Java when developing Android applications. After all, Android sdks are based on Java. However, Android fully supports C/C ++ development from the NDK r5 version. Whether pure C/C ++ is suitable for Android development remains to be verified.
Functions of using NDK:
1. supports Java + C development for Android applications
2. Improve code execution efficiency. The Byte Code Compiled by Java is parsed and compiled on JVM, which is much slower than the machine code compiled by C. The execution efficiency of C is 10 ~ higher than that of Java ~ 100 times
3. Implement the logic of the shielding program. Because the bytecode compiled by Java can be decompiled, and now the Java decompilation tool is particularly powerful, almost 100% of the source code can be seen. The machine code compiled by C can only be decompiled, and the assembly code is very ugly. As we all know, this protects the logic implementation of the program and is used in many commercial projects.
Disadvantages of NDK:
1. NDK is implemented locally and has certain requirements on the platform.
2. Unlike sdks, NDK does not have a variety of convenient UI and service-related class libraries, such as message event transmission and listening.
Shamoo checked relevant information and found that NDK not only supports C/C ++ development, but also supports inline assembly (more platform-dependent ), that is to say, Android Application Development supports Java + C/C ++ Assembly Development... great! In addition to the JNI interface, NDK also supports asni c and gnu c as well as native threads, OpenGL ES... learning about Linux C development or OpenGL ES development.