Software:Android NDK

From HandWiki
Revision as of 08:32, 9 February 2024 by JTerm (talk | contribs) (add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Android NDK
Developer(s)Google
Initial releaseJune 2009; 15 years ago (2009-06)[1]
Stable release
r25 / July 13, 2022; 2 years ago (2022-07-13)[1]
Written inC and C++
Operating system
PlatformIA-32 (Windows only) or x86-64 (Windows,[2] macOS and Linux)
Available inEnglish
TypeSDK
Websitedeveloper.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.[3][4] 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.[5][6]

Command-line tools can be compiled with the NDK and installed using adb.[7]

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:[8] 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[9] and Visual Studio.[10]

For CPU profiling, the NDK also includes simpleperf[11] which is similar to the Linux perf tool, but with better support for Android and specifically for mixed Java/C++ stacks.

References

  1. 1.0 1.1 "Android NDK | Android Developers". Developer.android.com. November 13, 2012. https://developer.android.com/ndk/downloads/revision_history. 
  2. "NDK Downloads | Android Developers" (in en). https://developer.android.com/ndk/downloads/index.html. 
  3. Ratabouil, Sylvain (2015). Android NDK beginner's guide : discover the native side of Android and inject the power of C/C++ in your applications (2nd ed.). Birmingham. ISBN 978-1-78398-965-2. OCLC 910639612. https://www.worldcat.org/oclc/910639612. 
  4. Kosarevsky, Sergey (2013). Android NDK game development cookbook : over 70 exciting recipes to help you develop mobile games for Android in C++. Viktor Latypov. Birmingham. ISBN 978-1-78216-779-2. OCLC 880639342. https://www.worldcat.org/oclc/880639342. 
  5. Srinivas, Davanum (December 9, 2007). "Android — Invoke JNI based methods (Bridging C/C++ and Java)". http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/. 
  6. "java.lang.System". Android Developers. http://developer.android.com/reference/java/lang/System.html. 
  7. "Android Debug Bridge (adb)". https://developer.android.com/studio/command-line/adb.html. 
  8. "Android NDK Native APIs | Android NDK". https://developer.android.com/ndk/guides/stable_apis. 
  9. "Using Eclipse for Android C/C++ Development". January 23, 2011. http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/. 
  10. "Using Visual Studio to Develop Native Android Code – VisualGDB Tutorials". https://visualgdb.com/tutorials/android/. 
  11. "Simpleperf | Android NDK". https://developer.android.com/ndk/guides/simpleperf.