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 – 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:

  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.

    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.

    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.

    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.

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.