Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android NDK Beginner`s Guide - Second Edition

You're reading from   Android NDK Beginner`s Guide - Second Edition Discover the native side of Android and inject the power of C/C++ in your applications

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher Packt
ISBN-13 9781783989645
Length 494 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sylvain Ratabouil Sylvain Ratabouil
Author Profile Icon Sylvain Ratabouil
Sylvain Ratabouil
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Setting Up Your Environment FREE CHAPTER 2. Starting a Native Android Project 3. Interfacing Java and C/C++ with JNI 4. Calling Java Back from Native Code 5. Writing a Fully Native Application 6. Rendering Graphics with OpenGL ES 7. Playing Sound with OpenSL ES 8. Handling Input Devices and Sensors 9. Porting Existing Libraries to Android 10. Intensive Computing with RenderScript 11. Afterword 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
    
    Time for action – preparing Ubuntu for Android development
  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
    
    Time for action – preparing Ubuntu for Android development
  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
    
    Time for action – preparing Ubuntu for Android development
  5. Install Ant with the following command (requires administrative privilege):
    sudo apt-get install ant
    

    Check whether Ant is properly working:

    ant -version
    
    Time for action – preparing Ubuntu for Android development

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.

You have been reading a chapter from
Android NDK Beginner`s Guide - Second Edition
Published in: Apr 2015
Publisher: Packt
ISBN-13: 9781783989645
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image