Android NDK学习(1) 简介

一、What is the NDK?

The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications.

Android applications run in the Dalvik virtual machine. The NDK allows you to implement parts of your applications using native-code languages such as C and C++. This can provide benefits to certain classes of applications, in the form of reuse of existing code and in some cases increased speed.

 Android NDK是一个工具集合,它可以让你利用原生代码在你的Android Applications中嵌入组件。。

Android应用在虚拟机上执行.NDK允许你的应用通过原生代码如C和C++去实现.这将给某些应用带来好处,这种方式能代码重用,并且在某些情况下提高执行速度。

NDK全称:Native Development Kit。

Android NDK 是配合 Android SDK 的工具,Google 推出NDK的目的不是为了取代Android SDK ,当然也不可能完全取代,它只是作为Android SDK  的一个补充。用来编译应用的原生代码。

  1、NDK是一系列工具的集合。

  * NDK提供了一系列的工具,帮助开发者快速开发C(或C++)的动态库,并能自动将so和java应用一起打包成apk。这些工具对开发者的帮助是巨大的。

  * NDK集成了交叉编译器,并提供了相应的mk文件隔离CPU、平台、ABI等差异,开发人员只需要简单修改mk文件(指出“哪些文件需要编译”、“编译特性要求”等),就可以创建出so。

  * NDK可以自动地将so和Java应用一起打包,极大地减轻了开发人员的打包工作。

  2、NDK提供了一份稳定、功能有限的API头文件声明。

Google明确声明该API是稳定的,在后续所有版本中都稳定支持当前发布的API。从该版本的NDK中看出,这些API支持的功能非常有限,包含有:C标准库(libc)、标准数学库(libm)、压缩库(libz)、Log库(liblog)。

二、What is the JNI?

 THE Java Native Interface (JNI) is a powerful feature of the Java platform.

Applications that use the JNI can incorporate native code written in programming languages such as C and C++, as well as code written in the Java programming language. The JNI allows programmers to take advantage of the power of the Java platform, without having to abandon their investments in legacy code. Because the JNI is a part of the Java platform, programmers can address interoperability issues once, and expect their solution to work with all implementations of the Java platform. 

JNI是Java Native Interface的缩写,中文为JAVA本地调用。从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。JNI一开始是为了本地已编译语言,尤其是C和C++而设计的,但是它并不妨碍你使用其他语言,只要调用约定受支持就可以了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章