Android.PK  
   
 
What is Android NDK ?  
 
 
Develop
Android plateform enables mobile apps developers to easily create useful mobile applications. ...
Market
Watch the top applications in action on Android Market Place or Publish your own apps. ...
Learn
Access to the entire platform source database and provides you a chance to learn Android  ...
 

The Android NDK is a companion tool to the Android SDK that lets you build performance-critical portions of your apps in native code. It provides headers and libraries that allow you to build activities, handle user input, use hardware sensors, access application resources, and more, when programming in C or C++. If you write native code, your applications are still packaged into an .apk file and they still run inside of a virtual machine on the device. The fundamental Android application model does not change.

Why use Android NDK ?

Using native code does not result in an automatic performance increase, but always increases application complexity. If you have not run into any limitations using the Android framework APIs, you probably do not need the NDK.

The NDK will not benefit most applications. As a developer, you need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but always increases application complexity. In general, you should only use native code if it is essential to your application, not just because you prefer to program in C/C++.

Typical good candidates for the NDK are self-contained, CPU-intensive operations that don't allocate much memory, such as signal processing, physics simulation, and so on. Simply re-coding a method to run in C usually does not result in a large performance increase. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need. The NDK can, however, can be an effective way to reuse a large corpus of existing C/C++ code.

The Android framework provides two ways to use native code:

  • Write your application using the Android framework and use JNI to access the APIs provided by the Android NDK. This technique allows you to take advantage of the convenience of the Android framework, but still allows you to write native code when necessary. You can install applications that use native code through the JNI on devices that run Android 1.5 or later.
  • Write a native activity, which allows you to implement the lifecycle callbacks in native code. The Android SDK provides the NativeActivity class, which is a convenience class that notifies your native code of any activity lifecycle callbacks (onCreate(), onPause(), onResume(), etc). You can implement the callbacks in your native code to handle these events when they occur. Applications that use native activities must be run on Android 2.3 (API Level 9) or later.

    You cannot access features such as Services and Content Providers natively, so if you want to use them or any other framework API, you can still write JNI code to do so.

System Requirements for Android NDK Installation

The NDK is designed for use only in conjunction with the Android SDK. If you have not already installed and setup the Android SDK, please do so before downloading the NDK.

The Android SDK

  • A complete Android SDK installation (including all dependencies) is required.
  • Android 1.5 SDK or later version is required.

Supported operating systems for Android NDk

  • Windows XP (32-bit) or Vista (32- or 64-bit)
  • Mac OS X 10.4.8 or later (x86 only)
  • Linux (32 or 64-bit; Ubuntu 8.04, or other Linux distributions using GLibc 2.7 or later)

Required development tools for Android NDK

  • For all development platforms, GNU Make 3.81 or later is required. Earlier versions of GNU Make might work but have not been tested.
  • A recent version of awk (either GNU Awk or Nawk) is also required.
  • For Windows, Cygwin 1.7 or higher is required. The NDK will not work with Cygwin 1.5 installations.

The NDK provides:

  • A set of tools and build files used to generate native code libraries from C and C++ sources
  • A way to embed the corresponding native libraries into an application package file (.apk) that can be deployed on Android devices.
  • A set of native system headers and libraries that will be supported in all future versions of the Android platform, starting from Android 1.5. Applications that use native activities must be run on Android 2.3 or later.
  • Documentation, samples, and tutorial

The latest release of the NDK supports the following instruction sets:

  • ARMv5TE (including Thumb-1 instructions)
  • ARMv7-A (including Thumb-2 and VFPv3-D16 instructions, with optional support for NEON/VFPv3-D32 instructions)
  • x86 instructions (see CPU-ARCH-ABIS.HTML for more information)

ARMv5TE machine code will run on all ARM-based Android devices.
ARMv7-A will run only on devices such as the Verizon Droid or Google Nexus One that have a compatible CPU.

The main difference between the two instruction sets is that ARMv7-A supports hardware FPU, Thumb-2, and NEON instructions. You can target either or both of the instruction sets — ARMv5TE is the default, but switching to ARMv7-A is as easy as adding a single line to the application's Application.mk file, without needing to change anything else in the file. You can also build for both architectures at the same time and have everything stored in the final .apk. Complete information is provided in the CPU-ARCH-ABIS.HTML in the NDK package.

The NDK provides stable headers for libc (the C library), libm (the Math library), OpenGL ES (3D graphics library), the JNI interface, and other libraries, as listed in the Development Tools section.

Development tools in Android NDK

The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin) platforms.

It provides a set of system headers for stable native APIs that are guaranteed to be supported in all later releases of the platform:

  • libc (C library) headers
  • libm (math library) headers
  • JNI interface headers
  • libz (Zlib compression) headers
  • liblog (Android logging) header
  • OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
  • libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).
  • A Minimal set of headers for C++ support
  • OpenSL ES native audio libraries
  • Android native application APIS

The NDK also provides a build system that lets you work efficiently with your sources, without having to handle the toolchain/platform/CPU/ABI details. You create very short build files to describe which sources to compile and which Android application will use them — the build system compiles the sources and places the shared libraries directly in your application project.

NOTE: With the exception of the libraries listed above, native system libraries in the Android platform are not stable and may change in future platform versions. Your applications should only make use of the stable native system libraries provided in this NDK.

Sample applications code and documentation is also included in package.

Android NDK Old Versions

Following are the Android NDK releases to date starting from June 2009

 Android NDK, Revision 7 (November 2011)
 Android NDK, Revision 6b (August 2011)
 Android NDK, Revision 6 (July 2011)
 Android NDK, Revision 5c (June 2011)
 Android NDK, Revision 5b (January 2011)
 Android NDK, Revision 5 (December 2010)
 Android NDK, Revision 4b (June 2010)
 Android NDK, Revision 3 (March 2010)
 Android NDK, Revision 2 (September 2009)
 Android NDK, Revision 1 (June 2009)

 

Android NDK Tutorial Video
Downloading & Installing the Android SDK
Platform Package Size
Windows android-ndk-r7b-windows.zip 80346206 bytes
Mac OS X (intel) android-ndk-r7b-darwin-x86.tar.bz2 73817184 bytes
Linux (i386) android-ndk-r7b-linux-x86.tar.bz2 64349733 bytes
  • Prepare your development computer and ensure it meets the system requirements.
  • Install the Android SDK
  • Install the ADT Plugin for Eclipse (if you'll be developing in Eclipse).
  • Add Android platforms and other components to your SDK.
  • Download and Install Android NDK package that is appropriate for your development computer
  • Uncompress the NDK download package using tools available on your computer
  • You may now rename the folder or use it with same name.
 
 
 
 
HOME
ABOUT
CONTACT
   
   
EVENTS
RESOURCES
TUTORIALS
BLOG
   
DEVELOP
MARKET
LEARN
   
   
   
 
 
Terms of Service - Privacy Policy Copyright © 2015 - Android for Pakistan
Android.pk Facebook Page Android.pk Twitter Linkedin Android.pk G+ Android.pk Youtube Channel