Android NDK: Beginner's Guide - Second Edition

More Information
  • Build your first Android native project from scratch
  • Communicate with Java through Java Native Interfaces
  • Learn the key design intricacies of creating a native OpenGL ES 2.0 graphics application
  • Initialize, play, and record sound and music with OpenSL ES
  • Handle input events and sensors to create different interaction types
  • Port an existing library on Android by compiling most common C++ frameworks on Android
  • Interface and optimize the existing code with RenderScript
  • Combine graphics, sound, input, sensors, and physics in your application

Android NDK is all about injecting high-performance and portable code into your mobile apps by exploiting the maximum speed of the device they run on.

This book will show you how to create C/C++-enabled mobile applications and integrate them with Java. The books starts with teaching you how to access native API and port libraries used in some of the most successful Android applications. Next, you will move on to create a real native application project through the complete implementation of a native API and porting existing third-party libraries. Moving forward, you will learn how to access the keyboard and input peripherals and read accelerometer or orientation sensors. Finally, you will dive into more advanced topics such as RenderScript.

  • Create high performance mobile applications with C/C++ and integrate with Java
  • Exploit advanced Android features such as graphics, sound, input, and sensing
  • Port and reuse your own or third-party libraries from the prolific C/C++ ecosystem
Page Count 494
Course Length 14 hours 49 minutes
ISBN 9781783989645
Date Of Publication 27 Apr 2015
Getting started with Android development
Time for action – preparing Windows for Android development
Time for action – installing Android SDK and NDK on Windows
Time for action – preparing OS X for Android development
Time for action – installing Android SDK and NDK on OS X
Time for action – preparing Ubuntu for Android development
Time for action – installing Android SDK and NDK on Ubuntu
Time for action – installing Eclipse with ADT on your OS
Time for action – creating an Android virtual device
Time for action – setting up an Android device
Building NDK sample applications
Time for action – compiling and deploying San Angeles sample
Creating your first native Android project
Time for action – creating a native Android project
Interfacing Java with C/C++
Time for action – calling C code from Java
Debugging native Android applications
Time for action – debugging a native Android application
Analyzing native crash dumps
Time for action – analyzing a native crash dump
Setting up a Gradle project to compile native code
Time for action – creating a native Android project
Time for action – using your own Makefiles with Gradle
Initializing a native JNI library
Time for action – defining a simple GUI
Time for action – initializing the native store
Converting Java strings in native code
Time for action – handling strings in the native store
Passing Java primitives to native code
Time for action – handling primitives in the native store
Referencing Java objects from native code
Time for action – saving references to Objects in native Store
Managing Java arrays
Time for action – handling Java arrays in native Store
Raising and checking Java exceptions
Time for action – raising & catching exceptions in native Store
Calling Java back from native code
Time for action – determining JNI method signatures
Time for action – calling back Java from native code
Time for action – allocating an object with JNI
Time for action – running and synchronizing a thread
Processing bitmaps natively
Time for action – decoding a camera's feed
Time for action – processing pictures with the Bitmap API
Creating a native Activity
Time for action – creating a basic native Activity
Handling Activity events
Time for action – stepping the event loop
Time for action – handling Activity events
Accessing window surface natively
Time for action – displaying raw graphics
Measuring time natively
Time for action – animating graphics with a timer
Initializing OpenGL ES
Time for action – initializing OpenGL ES
Time for action – clearing and swapping buffers
An insight into the OpenGL pipeline
Loading textures using the Asset manager
Time for action – reading assets with the Asset manager
Time for action – compiling and embedding libpng module
Time for action – loading a PNG image
Time for action – generating an OpenGL texture
Drawing 2D sprites
Time for action – initializing OpenGL ES
Rendering particle effects
Time for action – rendering a star field
Adapting graphics to various resolutions
Time for action – adapting resolution with off-screen rendering
Initializing OpenSL ES
Time for action – creating OpenSL ES engine and output
Playing music files
Time for action – playing background music
Playing sounds
Time for action – creating and playing a sound buffer queue
Recording sounds
Interacting with touch events
Time for action – handling touch events
Detecting keyboard, D-Pad, and Trackball events
Time for action – handling keyboard, D-Pad, and trackball events natively
Probing device sensors
Time for action – handling accelerometer events
Time for action – turning an Android device into a Joypad
Activating the Standard Template Library
Time for action – activating GNU STL in DroidBlaster
Time for action – read files with STL stream
Time for action – using STL containers
Porting Box2D to Android
Time for action – compiling Box2D on Android
Time for action – running Box2D physics engine
Prebuilding Boost on Android
Time for action – prebuilding Boost static library
Time for action – compiling an executable linked to Boost
Mastering module Makefiles
What is RenderScript ?
Executing a predefined Intrinsic
Time for action – creating a Java UI
Time for action – running RenderScript Blur intrinsic
Writing a custom Kernel
Time for action – writing a luminance threshold filter
Combining scripts together
Time for action – combining Intrinsics and scripts together


Sylvain Ratabouil

Sylvain Ratabouil is an IT consultant, experienced in Android, Java, and C/C++. He has contributed to the development of digital and mobile applications for large companies as well as industrial projects for the space and aeronautics industries. As a technology lover, he is passionate about mobile technologies and cannot live without his Android smartphone.