I apologize, the following should have been a comment, not a reply - because I donβt know what is wrong in your code, but here is what you can do to figure out yourself:
Here is my minimal Android.mk :
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello-jni LOCAL_SRC_FILES := HelloJni.cpp LOCAL_LDLIBS := -llog include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_CPPFLAGS := -std=c++11 NDK_TOOLCHAIN_VERSION=4.8 APP_STL=gnustl_static
And here is the minimal HelloJni.cpp
#include <jni.h> #include <thread> void doSomeWork( void ) { __android_log_print(ANDROID_LOG_DEBUG, "HelloJni", "hello from thread..."); return; } extern "C" jstring Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject thiz ) { std::thread t( doSomeWork ); t.join(); return env->NewStringUTF("Hello from JNI !"); }
It builds a clean r9b string on my Mac. One thing to check: run ndk-build V=1 and make sure the link step is similar to
~/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libhello-jni.so -shared --sysroot=~/android-ndk-r9b/platforms/android-17/arch-arm ./obj/local/armeabi/objs-debug/hello-jni/HelloJni.o ~/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/libgnustl_static.a -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -L~/android-ndk-r9b/platforms/android-17/arch-arm/usr/lib -llog -lc -lm -o ./obj/local/armeabi/libhello-jni.so
and check the output of the command
~/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86/bin/arm-linux-androideabi-nm -C ~/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/libgnustl_static.a | grep std::thread
Here is what I get:
00000000 T std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) 00000000 T std::thread::hardware_concurrency() 00000000 T std::thread::join() 00000000 T std::thread::detach()