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++而設計的,但是它並不妨礙你使用其他語言,只要調用約定受支持就可以了。

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