Shadab Ansari Shadab Ansari - 4 months ago 20x
Android Question

NDK not identifying certain header files like <mutex> and <future>

I am trying to integrate C++ files into my android project.
I tried using Android Studio's ndk feature but I got several issues. So I prevented Android Studio from creating its own file by making the following changes in my .gradle file -

sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'

And I created a gradle task to compile my library files.

task ndkBuild(type: Exec) {
commandLine ndk_build_path, '-C', file('src/main/jni').absolutePath

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild

where "ndk_build_path" is defined in file


The platform I'm using is Mac.

The header files in my C++ files are -

#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <vector>

#include <ctime>
#include <sys/time.h>
#include <cmath>
#include <queue>
#include <mutex>
#include <future>

I also created file with contents -

APP_ABI := all
APP_STL := gnustl_static
APP_STL :=stlport_static

I have put all the C++ files, and files in src/main/java/jni folder.

I am getting the following errors -

mutex: No such file or directory
future: No such file or directory

Please help !


I solved the issue by making the following changes- -

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)



APP_ABI := all
APP_STL := gnustl_static
APP_STL :=stlport_static
APP_STL :=c++_static

Hope someone could get some help with this.