Getting Started with the Tango C API

In this tutorial, we'll go through setting up your build environment and compiling and running your first "Hello Tango" project using the C API, which will run sample code and display the pose data from your device.


To successfully follow this guide, you will need:

  • A recent version of Android Studio.

  • The most recent version of the Android NDK and associated tools. To install them, follow this guide.

  • Experience developing Android apps. If you have never created an Android app before, you can get started with the Building Your First App tutorial.

  • A Tango device. You can build the code without one, but you won't be able to run it.

Download the sample project

The sample project is hosted on GitHub. You can download it as a zip file or use git to clone the repository:

git clone

You should now have a directory called tango-examples-c on your machine. Within this directory you should see a subdirectory called cpp_basic_examples, which contains the code for this guide.

Import the project into Android Studio

  1. Do one of the following:

    • Open Android Studio.
    • If you are already in Android Studio with a project loaded, close the project.

    Either action takes you to the Welcome to Android Studio screen.

  2. Select Import Project (Eclipse ADT, Gradle, etc.). In older versions of Android Studio, this may be Import Non-Android Studio project or simply Import Project.

  3. In the Select Eclipse or Gradle Project to Import dialog, navigate to the repository you just cloned. Choose the cpp_basic_examples directory and then click OK.

Set up your environment

Installing the NDK using the SDK manager should automatically set your NDK path. If you downloaded the NDK manually, you will need to set the path yourself. Go to File > Project Structure, and fill in the Android NDK location: section as appropriate.

Older versions of Android Studio may need to set the path directly in the Gradle Scripts. In the Gradle Scripts directory, open the file and then add the ndk.dir property under the sdk.dir property that is already there:


If you are using Windows, you may need to edit your build.gradle file to fix the ndkbuild path. Open the file and change the ndkbuild path from ndk-build to ndk-build.cmd.

// ...
task ndkBuild(type: Exec) {
    Properties properties = new Properties()
    def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build.cmd"
    commandLine ndkbuild, '-C', file('src/main/jni').absolutePath

Connect your device

If you haven't already done so, connect your Tango device to your computer.

Build and run an application

Within the basic examples project you loaded, you have a choice of several different "hello"-style apps to build and run. For this tutorial, we'll choose "Hello Motion Tracking."

  1. On the toolbar, view the Run/Debug Configuration field and make sure hello_motion_tracking is the active configuration. If it is not, click the field and select it.

  2. Do one of the following:

    • On the Run menu, click Run.
    • On the toolbar, click the Run button (the green arrow).
  3. In the Device Chooser dialog, select Choose a running device, then select your Tango tablet, and then click OK.

View the raw pose data in logcat

The logcat output appears automatically in the bottom part of Android Studio.

To see the logcat output in your terminal:

  • Use the adb logcat command:

    sdk-path/platform-tools/adb logcat

Here is a brief example of the pose data that appears in your terminal:

I/cpp-hello-tango(13862): Position: -0.007565, -0.000628,
-0.016770. Orientation: 0.642147, -0.026346, 0.765854, 0.765854

Next steps

Now that you have learned how to set up your environment for development with the Tango C API, proceed to the following links to learn how to use specific features of Tango in your app:

Also, take a look at the rest of our code samples on Github.

Send feedback about...

Tango C API
Tango C API