Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – preparing Ubuntu for Android development


To develop with the Android NDK on Linux, we need to set up a few prerequisites: Glibc, Make, OpenJDK, and Ant.

  1. From Command Prompt, check whether Glibc (the GNU C standard library) 2.7 or later, usually shipped with Linux systems by default, is installed:

    ldd -–version
    
  2. Make is also required to build native code. Install it from the build-essential package (requires administrative privilege):

    sudo apt-get install build-essential
    

    Run the following command to ensure Make is correctly installed, in which case its version is displayed:

    make –version
    
  3. On 64-bit Linux systems, install the 32-bit libraries compatibility package, as Android SDK has binaries compiled for 32 bits only. To do so on Ubuntu 13.04 and earlier, simply install the ia32-libs package:

    sudo apt-get install ia32-libs
    

    On Ubuntu 13.10 64 bits and later, this package has been removed. So, install the required packages manually:

    sudo apt-get install lib32ncurses5 lib32stdc++6 zlib1g:i386 libc6-i386
    
  4. Install Java OpenJDK 7 (or JDK 8, although it is not officially supported at the time this book is written). Oracle JDK is also fine:

    sudo apt-get install openjdk-7-jdk
    

    Ensure JDK is properly installed by running Java and checking its version:

    java –version
    
  5. Install Ant with the following command (requires administrative privilege):

    sudo apt-get install ant
    

    Check whether Ant is properly working:

    ant -version
    

What just happened?

Our Linux system is now prepared with the necessary packages to host Android development tools:

  • The build-essential package, which is a minimal set of tools for compilation and packaging on Linux Systems. It includes Make, which is required by the Android NDK compilation system to build native code. GCC (the GNU C Compiler) is also included but is not required as Android NDK already contains its own version.

  • 32-bit compatibility libraries for 64-bit systems, since the Android SDK still uses 32-bit binaries.

  • A JDK 7, which contains the runtime and tools necessary to build Java applications on Android and run the Eclipse IDE as well as Ant.

  • Ant, which is a Java-based build automation utility. Although not a requirement, it allows building Android applications from the command line, as we will see in Chapter 2, Starting a Native Android Project. It is also a good solution to set up a continuous integration chain.

The next step consists of setting up the Android development kits.

Installing Android development kits on Linux

Android requires specific development kits to develop applications: the Android SDK and NDK. Hopefully, Google has thought about the developer community and provides all the necessary tools for free.

In the following part, we will install these kits to start developing native Android applications on Ubuntu 14.10 Utopic Unicorn.