The difference between JNI and NDK

Source: Internet
Author: User
Tags file system

NDK (Native Development Kit) "native" means binary

Android is often developed in Java-encapsulated libraries, and the underlying implementation of these libraries is implemented by C/s, such as media, graphics libraries, etc.

Java calls are implemented in such a way that it requires JNI (Java Native Interface)

At ordinary times, that is, Google to our package of good library, that is, the underlying implementation is not Java, but there is a unified Java interface

The role of NDK is to "write our own local code" (c + +) and to encapsulate it into a Java interface with JNI

For example, we want to do a calculation, obviously this is not a Java strength, but can be used to write the implementation of C/S, to return an operation results on the line

NDKR5 has implemented not to write a line of Java code Development program, but still use the virtual machine, the details are encapsulated hidden

Many Android developers for JNI and NDK do not understand this problem

JNI is the Java invoke Native mechanism, the Java language's own features are all called Java Native Interface, and similar to the P/invoke on the Microsoft. Net Framework, you can have C # or Visual Basic.NET call C/ C + + API, so the JNI and Android are not related to the development of Java applications on the PC, if running on the Windows platform using JNI is often, such as reading and writing Windows registry.

NDK is Google's launch to help Android developers to write applications through the C + + local language application of the development package, including C/s + + header files, library files, documentation and sample code, we can understand as the Windows Platform SDK, is pure C/s Written, but Android does not support the applications written by pure/C + +, while NDK provides a limited library and function functions, only to deal with some of the efficiency-sensitive issues, so Android123 recommended beginners Learn Java and then learn JNI.

NDK in fact, it is important to have a package of. So and. apk.

and JNI development is not packaged, just put the. so file in a specific location in the file system.

If you are doing application development, you need to NDK tools, otherwise how do you develop applications for users? Did you help him recompile the file system?

Other as for implementation, Java calls local C + + functions, and its way of writing, I think JNI and NDK no difference.

There's another one I personally understand, NDK develop C + + can only use NDK own limited header file, while using JNI can use the file system with the header file, such as Utils/log.h

While the latter has more resources, of course NDK is working to develop it to support richer interfaces.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.