Installing Tegra Android Development Pack
TADP was released by NVIDIA to make the preparation for the Android development environment a seamless process.
NVIDIA has released TADP version 3.0r4 to support Android SDK (23.0.2), NDK (r10c), and OpenCV for Tegra 2.4.8.2, which is a regular OpenCV4Android SDK extended with Tegra-specific optimizations.
Downloading and installing TADP
To get TADP, visit https://developer.nvidia.com/tegra-android-development-pack and follow the steps to become a registered developer; it is a free membership.
Once you have your membership activated, log in and download the version corresponding to your operating system. NVIDIA supports the following operating systems:
- Windows 64-bit
- Mac OS X
- Ubuntu Linux (32/64-bit)
In my case, I have Windows 7 64-bit on my machine, so from now on, all the upcoming steps are tested and working fine on this operating system. However, I don't expect any major changes if you are working with a different operating system.
Note
For the Ubuntu installation, TADP will need you to have root privileges, so make sure that you do.
Once you finish downloading the TADP installer, launch it and perform the following steps:
- Follow the onscreen instructions after you read and accept the license agreement.
- You will need to choose the type of installation. Select a Custom installation and click on the Next button:
- Select the components to be installed as depicted and click on the Next button:
- You need to name the installation and download the directory.
Note
Note that if you have a previous installation, you will get a warning message that the previous installation needs to be uninstalled. To uninstall the previous installation, go to the previous installation directory and run
tadp_uninstall.exe
.Sometimes, the uninstaller doesn't clean everything. In this case, you need to delete the contents of the previous installation directory manually.
- Now you are ready to install the selected components. Click on the Next button.
- In case you are behind a proxy, you can enter the proxy details; otherwise, click on the Next button.
- The installer will start to download all the selected components; this may take a while depending on your Internet connection.
- After the download has finished, click Next to start installing the selected components.
Note
Sometimes, the installer window will not respond; this is okay. After a few minutes, the installation will continue in a normal way.
- Select the post-installation action that you want and click on the Finish button.
TADP post-installation configuration
Yes, TADP will download and install everything for you; yet you still need to do some post-installation configuration in order to make sure that everything will work properly.
Installing emulator system images
You need to install a system image for every Android SDK platform installed in case you want to run an emulator with this SDK platform as a target.
To do so, just follow these simple steps:
- Go to the installation directory that you selected while installing TADP.
- Open the SDK folder; in this case, it is
android-sdk-windows
. - Run the SDK Manager.
- For every installed Android X.X, select a system image for the emulator, such as ARM EABI V7a System Image:
- Click Install packages.
- Read and accept the license agreement for the selected components.
- Click Install.
Now, you can test your applications on an emulator of any of the installed targets.
Configuring Eclipse to work with NDK
You also need to configure Eclipse to run with NDK so that you can build your native apps directly from Eclipse:
- Launch Eclipse from the installation directory that you specified earlier.
- Open Window | Preferences.
- In the pane on the left-hand side, open Android Tree.
- Select the tree node labeled NDK.
- In the right pane, click Browse and select the NDK directory; you will find it under the installation directory.
- Click OK.
NDK verification
As the OpenCV libraries are written in C/C++, the first step to verify that your environment is working is to make sure that you are able to run Android applications that use native code:
- Launch Eclipse.
- From the NDK installation directory—in my case,
C:\NVPACK\android-ndk-r10c\
—import thehello-jni
sample project from thesamples
folder as if you are importing any other Android project. - Right-click on the
HelloJni
project. - In the context menu, choose Android Tools | Add Native Support.
- Make sure that the library name is set to
hello-jni
; it should be named this by default. - Start the emulator with the target of your choice.
- Right click on the
hello-jni
project in the project explorer. In the context menu, choose Run as | Android application.
In your console output, there should be a list of .so
files; these are the native shared libraries that NDK has built using Application Binary Interface (ABI), which defines exactly how your machine code should look.
Android NDK supports different architectures. By default, your .so
will be built for ARM EABI in addition to MIPS and x86 if you specify so in the application.mk
file. We will discuss this subject later in this chapter.
If everything runs smoothly, your emulator should have an app running as follows:
This application is very simple and a good checkpoint to verify that you are able to invoke native code from your Android application.
Basically, what you see on the emulator screen is a string returned from the native code and displayed by the Android framework in a text view.