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 Native Development Kit Cookbook

You're reading from   Android Native Development Kit Cookbook Create Android apps using Native C/C++ with the expert guidance contained in this cookbook. From basic routines to advanced multimedia development, it helps you harness the full power of Android NDK.

Arrow left icon
Product type Paperback
Published in Mar 2013
Publisher Packt
ISBN-13 9781849691505
Length 346 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Liu Feipeng Liu Feipeng
Author Profile Icon Liu Feipeng
Liu Feipeng
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Android Native Development Kit Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Hello NDK 2. Java Native Interface FREE CHAPTER 3. Build and Debug NDK Applications 4. Android NDK OpenGL ES API 5. Android Native Application API 6. Android NDK Multithreading 7. Other Android NDK API 8. Porting and Using the Existing Libraries with Android NDK 9. Porting an Existing Application to Android with NDK Index

Setting up an Android NDK development environment in Mac OS


This recipe describes how to set up an Android NDK development environment in Mac OS.

Getting ready

Android development requires Mac OS X 10.5.8 or higher, and it works on the x86 architecture only. Ensure that your machine meets these requirements before getting started.

Register an Apple developer account, then go to https://developer.apple.com/xcode/ to download Xcode, which contains a lot of developer tools, including the make utility required for Android NDK development. After the download is complete, run the installation package and make sure that the UNIX Development option is selected for installation.

As usual, Java JDK 6 or above is required. Mac OS X usually ships with a full JDK. We can verify that your machine has the required version by using the following command:

$javac -version

How to do it…

Setting up an Android NDK development environment on Mac OS X is similar to setting it up on Ubuntu Linux. The following steps explain how we can do this:

  1. Follow steps 1 to 6 of the Setting up an Android NDK development environment in Windows recipe to install the ADT plugin for Eclipse.

  2. Download Android SDK from http://developer.android.com/sdk/index.html, then extract the downloaded package.

  3. Append the following lines to ~/.profile. If the file doesn't exist, create a new one. Save the changes and log out of the current session:

    export ANDROID_SDK=<path to Android SDK directory>
    export PATH=$PATH:$ ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
  4. In Eclipse, select Eclipse | Preferences to open the Preferences window. Select Android from the left panel, then click on Browse to locate the Android SDK root directory. Click on Apply, and then OK.

  5. In a terminal, start the Android SDK Manager at the tools directory by typing the command android. Select Android SDK Tools, Android SDK Platform-tools, at least one Android platform (the latest one is preferred), System Image, SDK Samples, and Android Support. Then click on Install. In the next window, read and accept all the license agreements, then click on Install.

  6. Download Android SDK from http://developer.android.com/sdk/index.html, and then extract the downloaded package.

  7. Change the lines that you appended to ~/.profile in step 3:

    export ANDROID_SDK=<path to Android SDK directory>
    export ANDROID_NDK=<path to Android NDK directory> 
    export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK
  8. Start a new terminal, then go to the samples/hello-jni directory in NDK. Type the command ndk-build. If the build is successful, it proves that the NDK environment is set up correctly.

How it works…

The steps to set up an Android NDK development environment on Mac OS X are similar to Ubuntu Linux, since both of them are Unix-like operating systems. We first installed Android SDK, then Android NDK.

lock icon The rest of the chapter is locked
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