Book Image

Mastering Android NDK

Book Image

Mastering Android NDK

Overview of this book

Android NDK is used for multimedia applications that require direct access to system resources. NDK is also the key for portability, which in turn allows a reasonably comfortable development and debugging process using familiar tools such as GCC and Clang toolchains. This is a hands-on guide to extending your game development skills with Android NDK. The book takes you through many clear, step-by-step example applications to help you further explore the features of Android NDK and some popular C++ libraries and boost your productivity by debugging the development process. Through the course of this book, you will learn how to write portable multi-threaded native code, use HTTP networking in C++, play audio files, use OpenGL ES 3, and render high-quality text. Each chapter aims to take you one step closer to building your application. By the end of this book, you will be able to create an engaging, complete gaming application.
Table of Contents (17 chapters)
Mastering Android NDK
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using Android command-line tools on Windows


To start developing native C++ applications for Android in a Microsoft Windows environment, you will need some essential tools to be installed on your system.

Start NDK development for Android using the following list of all the prerequisites you will need:

The current versions of these tools will run on Windows without using any intermediate compatibility layer; they do not require Cygwin any more.

As much as it pains us to write this, Android SDK and NDK should still be installed into folders that do not contain any whitespaces in their names. This is a limitation of build scripts within the Android SDK; the unquoted environment variables content are split into words based on tab, space and newline characters.

We will install the Android SDK to D:\android-sdk-windows, the Android NDK to D:\ndk, and other software to their default locations.

In order to compile our portable C++ code for Windows, we need a decent toolchain. We recommend using the latest version of the MinGW from the Equation package available at http://www.equation.com. You can choose 32- or 64-bit versions as you go.

Once all the tools are in their folders, you need to set environment variables to point to those install locations. The JAVA_HOME variable should point to the Java Development Kit folder:

JAVA_HOME="D:\Program Files\Java\jdk1.8.0_25"

The NDK_HOME variable should point to the Android NDK installation folder:

NDK_HOME=D:\NDK

The ANDROID_HOME should point to the Android SDK folder:

ANDROID_HOME=D:\\android-sdk-windows

Note

Note the double backslash in the last line.

Both NDK and SDK will have new versions from time to time, so it might be helpful to have the version number on the folder name and manage NDK folders per project if necessary.