Chapter 3. Build and Debug NDK Applications

In this chapter we will cover the following recipes:

  • Building an Android NDK application at the command line
  • Building an Android NDK application in Eclipse
  • Building an Android NDK application for different ABIs
  • Building an Android NDK applications for different CPU features
  • Debugging an Android NDK application with logging messages
  • Debugging an Android NDK application with CheckJNI
  • Debugging an Android NDK application with NDK GDB
  • Debugging an Android NDK application with CGDB
  • Debugging an Android NDK application in Eclipse

Introduction

We covered the environment set up in Chapter 1, Hello NDK, and JNI programming in Chapter 2, Java Native Interface. To build Android NDK applications, we'll also need to use the build and debug tools for Android NDK.

Android NDK comes with the ndk-build script to facilitate the easy build of any Android NDK application. This script hides the complications of invoking cross compilers, cross linkers, and so on, from developers. We'll start by introducing the usage of the ndk-build command.

A recent release of the Android Development Tools (ADT) plugin has enabled the building of Android NDK applications from Eclipse. We'll demonstrate how to use it.

We'll explore building NDK applications for different Application Binary Interfaces (ABIs) and making use of optional CPU features. This is essential to achieve best performance on different Android devices.

Besides build, we will also introduce various debugging tools and techniques for Android NDK applications. Starting with the simple but powerful logging technique, we'll show how to debug NDK applications from both the command line and the Eclipse IDE. The CheckJNI mode will also be introduced, which can help us capture JNI bugs.

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

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