What Is In the NDK?

The NDK is a set of tools you use to develop native code for your application. Everything is in a single directory, which you download as an archive file from http://d.android.com/sdk/ndk. For example, the Windows version of the NDK revision 6b contains these directories:

  • build
  • docs
  • platforms
  • samples
  • sources
  • tests
  • toolchains

A few files are also located at the root of the NDK directory:

  • documentation.html
  • GNUmakefile
  • ndk-build
  • ndk-gdb
  • ndk-stack
  • README.txt
  • RELEASE.txt

The NDK documentation is nowhere near as thorough as the SDK on http://d.android.com, so start by opening documentation.html with your favorite web browser. The README text file is also begging you so go ahead and oblige.

The NDK is a collection of six components:

  • Documentation
  • Header files
  • C/C++ files
  • Precompiled libraries
  • Tools to compile, link, analyze, and debug your code
  • Sample applications

Native code is, by definition, specific to a certain architecture. For example, an Intel CPU would not understand ARM instructions, and vice versa. Therefore, the NDK includes precompiled libraries for multiple platforms as well as different versions of tools. NDK revision 7 supports three Application Binary Interfaces (ABIs):

  • armeabi
  • armeabi-v7a
  • x86

NOTE: The NDK does not support the ARMv6 ABI.

Most of you are already familiar with the x86 name as it refers to the Intel architecture, a name that is practically ubiquitous. The armeabi and armeabi-v7a names may not sound familiar, but you can find ARM-based chips in many products, from washing machines to DVD players, so chances are you used an ARM-based device long before you even heard of Android. Close to 2 billion ARM-based chips were shipped in the second quarter of 2011 alone: 1.1 billion in mobile phones and tablets, and 0.8 billion in other consumer and embedded devices.

The term “armeabi” stands for ARM Embedded Application Binary Interface, while v5 and v7a refer to two different architectures. ARM architectures started with v1, and the latest one is v7. Each architecture is used by a family of processor cores, with v5 being used by some ARM7, ARM9, and ARM10 cores, and v7 by the Cortex family. The Cortex series includes A5, A8, A9, and soon A15, with the majority of today's smartphones and tablets using A8 and A9 cores.

The Android NDK does not support the ARMv6 architecture, which is used by the ARM11 family of processor cores, even though some Android devices use ARM11-based chipsets. Table 2–1 shows a list of Android devices.

Image

While MIPS Technologies announced that a MIPS-based smartphone running Android 2.2 passed the Android CTS back in June 2011, the Android NDK still does not support the MIPS ABI. As of today, ARM is still the dominant architecture in Android devices.

NOTE: All Google TV devices released in 2010 (Logitech set-top box, Sony TVs, and Blu-ray player) are based on the Intel CE4100. However, the Google TV platform currently does not support the NDK.

As the NDK is frequently updated, you should always try to use the latest revision. New revisions may improve performance, for example by providing better compilers or more optimized precompiled libraries. New revisions can also fix bugs from previous revisions. When publishing an update to your application, consider rebuilding your C/C++ code with the latest NDK even if you modified only the Java part of your application. However, make sure you always run tests on the C/C++ code! Table 2–2 shows the NDK revisions.

Image
Image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.19.26