<== Chapter 2 -- Chapter 4 ==>
Chapter 3 - Loading Tango API Libraries
The Tango API's are just like any C library where you have your include folder with the header files, the lib folder with the compiled shared library file and now its just a matter of have it build along with your Android APK.
Where is the library
- The download site currently is on the offical Google Tango Developer site
- You will want to download at least the client API (also named Tango SDK for C on site)
- Also download the support API or 3D Reconstruction as needed
How to add it to Android.mk
- First note, the names of files/folders are mainly arbitrary, but for best interest I would advise you to stick with the below naming conventions.
- We first will start by making a folder called
tango_client_apito hold the library - Inside we will have two subfolders:
includeandlibincludewill hold thetango_client_api.hheader filelibwill have a subfolder for each architecture- Note: if you know for sure you only need one then have one
- The two subfolders used here are
arm64-v8aandarmeabi-v7a - Each of these subfolders contain the
libtango_client_api.solibrary - For this tutorial you will also need the
libtango_client_stub.afile in yourlibfolder found here. This static file is JUST for the client API
-
To build this library itself we will include an
Android.mkfile inside thetango_client_apifolder.- You can find the file here, but we are also going to break down what the
Android.mkfile is doing: ``` LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) LOCAL_MODULE := tango_client_api
ifeq ($(TARGET_ARCH), arm64) LOCAL_EXPORT_LDLIBS := -L$(LOCAL_PATH)/lib/arm64-v8a -ltango_client_api endif
ifeq ($(TARGET_ARCH), arm) LOCAL_EXPORT_LDLIBS := -L$(LOCAL_PATH)/lib/armeabi-v7a -ltango_client_api endif
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_SRC_FILES := lib/libtango_client_stub.a
include $(PREBUILT_STATIC_LIBRARY)
`` * First we always start our makefiles with defining theLOCAL_PATHto the directory ourAndroid.mklives. Then we also always callinclude $(CLEAR_VARS)to clear unwanted local enviroment variables. * We load the module by name which in this case we just left out the "lib" prefix * Next we decided which architecture its building for and link it to the path of the.sofile as well and telling the linker to include it with the-ltango_client_apiflag * Next we export include the header file location * For the client API **ONLY** we also include the static file we added * Last thing we do is tell it generate the library as a Prebuilt Static library * We repeat the steps above for the support and 3D Reconstruction API as needed and then we can now add it to the mainAndroid.mkproject file * Here is the link to the [main project Android.mk file](../../Section_04_Project/Sample_Code/Tango-NDK-Tutorial/app/src/main/cpp/Android.mk) which we now need to add a few lines *LOCAL_SHARED_LIBRARIES := tango_client_apiis where we declare the shared libraries we plan to include *$(call import-add-path, $(PROJECT_ROOT))is used to add the folder location of yourtango_client_apifolder locations * Note: If you want to move yourtango_client_apifolder just create a path to the directory and add another line such as$(call import-add-path, $(PATH_TO_MY_TANGO_CLIENT_API_FOLDER))for example * The last thing we need to do is actually import the module we built using$(call import-module,tango_client_api)` which calls it in. - You can find the file here, but we are also going to break down what the