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 – installing Eclipse with ADT on your OS

Since the latest Android SDK releases, Eclipse and its plugins (ADT and CDT) need to be installed manually. To do so execute the following steps:

  1. Go to http://www.eclipse.org/downloads/ and download Eclipse for Java developers. Extract the downloaded archive in the directory of your choice (for example, C:\Android\eclipse on Windows, ~/ Android/Eclipse on Linux, and ~/Library/Android/eclipse on Mac OS X).

    Then, run Eclipse. If Eclipse asks for a workspace (which contains Eclipse settings and projects) when starting up, define the directory of your choice or leave the default settings and then click on OK.

    When Eclipse has finished loading, close the welcome page. The following window should appear:

    Time for action – installing Eclipse with ADT on your OS
  2. Go to Help | Install New Software…. Enter https://dl-ssl.google.com/android/eclipse in the Work with: field and validate. After a few seconds, a Developer Tools plugin appears. Select it and click on the Next button.

    Tip

    In case this step fails while accessing update sites, check your Internet connection. You may be either disconnected or connected behind a proxy. In the latter case, you can download the ADT plugin as a separate archive from the ADT web page and install it manually, or configure Eclipse to connect through a proxy.

    Time for action – installing Eclipse with ADT on your OS

    Follow the wizard and accept conditions when asked. On the last wizard page, click on Finish to install ADT. A warning may appear indicating that the plugin content is unsigned. Ignore it and click on OK. When finished, restart Eclipse as requested.

  3. Go back to Help | Install New Software…. Open the Work with combobox and select the item containing the Eclipse version name (here, Luna). Then, check the Show only software applicable to target environment option. Find Programming Languages in the plugin tree and unfold it. Finally, check all C/C++ plugins and click on Next.
    Time for action – installing Eclipse with ADT on your OS

    Follow the wizard and accept conditions when asked. On the last wizard page, click on Finish. Wait until the installation is complete and restart Eclipse.

  4. Go to Windows | Preferences... (Eclipse | Preferences... on Mac OS X) and then select Android on the left tree. If everything is fine, the SDK Location should be filled with the Android SDK path.
    Time for action – installing Eclipse with ADT on your OS

    Then, on the same window, go to Android | NDK. The NDK Location field should be empty. Fill it with the Android NDK path and validate. If the path is wrong, Eclipse complains that the directory is not valid.

    Time for action – installing Eclipse with ADT on your OS

What just happened?

Eclipse is now up and running with the appropriate SDK and NDK configuration. Since the ADT package is no longer provided by Google, the Android development plugin ADT and the C/C++ Eclipse plugin CDT have to be installed manually in Eclipse.

Please note that Eclipse has been deprecated by Google and replaced by Android Studio. Sadly, Android Studio C/C++ and NDK support is rather limited for the moment. The only way to build native code is through Gradle, the new Android build system, whose NDK features are still unstable. If a comfortable IDE is essential to you, you can still use Android Studio for Java development and Eclipse for C/C++ though.

If you work on Windows, maybe you are Visual Studio adept. In that case, I advise you that a few projects, shown as follows, bring Android NDK development to Visual Studio:

  • Android++, which is a free extension for Visual Studio that can be found at http://android-plus-plus.com/. Although still in Beta at the time this book is written, Android++ looks quite promising.
  • NVidia Nsight, which can be downloaded with a developer account from the Nvidia developer website at https://developer.nvidia.com/nvidia-nsight-tegra (if you have a Tegra device). It packages together the NDK, a slightly customized version of Visual Studio, and a nice debugger.
  • VS-Android, which can be found at https://github.com/gavinpugh/vs-android, is an interesting Open Source project, which brings NDK tools to Visual Studio.

Our development environment is now almost ready. The last piece is missing though: an environment to run and test our applications.

Setting up the Android emulator

The Android SDK provides an emulator to help developers who want to speed up their deploy-run-test cycle or want to test, for example, different kinds of resolutions and OS versions. Let's see how to set it up.

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