Android NDK

{{Distinguish|Android SDK}}

{{Infobox software

| title = Android NDK

| logo =

| logo caption =

| screenshot =

| caption =

| collapsible =

| developer = Google

| released = {{Start date and age|2009|6}}{{cite web|url=https://developer.android.com/ndk/downloads/revision_history |title=Android NDK | Android Developers |publisher=Developer.android.com |date=November 13, 2012 |access-date=March 13, 2014}}

| discontinued =

| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}

| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}

| latest preview version =

| status =

| programming language = C and C++

| operating system = {{Plainlist|

}}

| platform = IA-32 (Windows only) or x86-64 (Windows,{{Cite web|url=https://developer.android.com/ndk/downloads/index.html|title=NDK Downloads {{!}} Android Developers|website=developer.android.com|language=en|access-date=2018-04-24}} macOS and Linux)

| size =

| language = English

| genre = SDK

| license =

| website = {{URL|https://developer.android.com/ndk/}}

}}

The Android Native Development Kit (NDK) provides a cross-compiling tool for compiling code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) for Android.{{Cite book|last=Ratabouil|first=Sylvain|url=https://www.worldcat.org/oclc/910639612|title=Android NDK beginner's guide : discover the native side of Android and inject the power of C/C++ in your applications|date=2015|isbn=978-1-78398-965-2|edition=2nd|location=Birmingham|oclc=910639612}}{{Cite book|last=Kosarevsky|first=Sergey|url=https://www.worldcat.org/oclc/880639342|title=Android NDK game development cookbook : over 70 exciting recipes to help you develop mobile games for Android in C++|date=2013|others=Viktor Latypov|isbn=978-1-78216-779-2|location=Birmingham|oclc=880639342}} The NDK uses the Clang compiler to compile C/C++. GCC was included until NDK r17, but removed in r18 in 2018.

Overview

Native libraries can be called from Java code running under the Android Runtime using System.loadLibrary, part of the standard Android Java classes.{{cite web|url= http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/ |title=Android — Invoke JNI based methods (Bridging C/C++ and Java) |last=Srinivas |first=Davanum |date=December 9, 2007 |access-date=December 13, 2008| archive-url= https://web.archive.org/web/20081216084711/http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/| archive-date= December 16, 2008 | url-status= live}}{{cite web|url= http://developer.android.com/reference/java/lang/System.html |title=java.lang.System |work=Android Developers |access-date=September 3, 2009}}

Command-line tools can be compiled with the NDK and installed using adb.{{Cite web | url=https://developer.android.com/studio/command-line/adb.html |title = Android Debug Bridge (adb)}}

Android uses Bionic as its C library, and the LLVM libc++ as its C++ Standard Library. The NDK also includes a variety of other APIs:{{Cite web | url=https://developer.android.com/ndk/guides/stable_apis |title = Android NDK Native APIs | Android NDK}} zlib compression, OpenGL ES or Vulkan graphics, OpenSL ES audio, and various Android-specific APIs for things like logging, access to cameras, or accelerating neural networks.

The NDK includes support for CMake and its own ndk-build (based on GNU Make). Android Studio supports running either of these from Gradle. Other third-party tools allow integrating the NDK into Eclipse{{cite web|url= http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/ |title=Using Eclipse for Android C/C++ Development|date=January 23, 2011}} and Visual Studio.{{Cite web|url=https://visualgdb.com/tutorials/android/|title=Using Visual Studio to Develop Native Android Code – VisualGDB Tutorials|date=30 April 2015 }}

For CPU profiling, the NDK also includes simpleperf{{Cite web | url=https://developer.android.com/ndk/guides/simpleperf | title=Simpleperf | Android NDK}} which is similar to the Linux perf tool, but with better support for Android and specifically for mixed Java/C++ stacks.

References