Site icon Experience, Digital Engineering and Data & Analytics Solutions by Apexon

Android development – Marrying Android with NDK Part1

Testing

Introduction

Since it’s first release in 2008 from Google and the Open Handset Alliance, Android has become one of the largest mobile platform in the world. With it’s flexibility features, customizable platform, over 67% of mobile application developers uses Android. As of April 2013, Google play had 850,000+ active applications available for download. Most of the android applications are written in Java with Android Software Development Kit (SDK). While writing pure Java applications, developers often feel the need to call native C/C++ libraries. This is where Android NDK plays a role.

In this paper we will introduce you to the Android NDK and it’s capabilities through the following topics:

Why is NDK Important?

It makes sense to run highly optimized, self-contained routines which do not require much RAM, such as signal processing routines, physics simulations in their native form as these components might run better in native or at least might not be worth to port and optimize if gains are small.

What is NDK?

Android applications runs in the Dalvik Virtual Machine. And Android NDK is a toolset that lets you embed components that make use of native code languages such as C and C++. Using NDK, developers can build and cross-compile native code for the device specific architecture.

Components of  NDK?

Latest NDK (r8), supports ARMv5TE, ARMv7-A, x86 and MIPS.

JNI

Java offers  Java  Native  Interface as a framework connecting Java to the native code. Before using NDK, you should be  familiar with JNI.

Using the NDK

Overview

 

  1. Create .java class representing the native code
  2. Create the native code header file
  3. Native code implementation by writing C code
  4. Compile and build shared library
  5. Use native methods from java class.

Understanding NDK and JNI with an example

Follow below steps to develop JNI libraries,

The steps that you have to take to develop JNI libraries for Android phones are simple in principle. They are outlined below.

Exit mobile version