Now that Android Studio 2.2 is officially released, I am moving from my old ndk-build process to try using CMake inside AS. Since I include several codebases inside my company (which I cannot edit) that heavily use C ++ 11 code (including the awful std :: to_string () method), the only way I can compile is to use several configuration options - all this I discovered earlier when I started working with ndk-build. (see below)
So, everything is compiled and embedded in the APK again - and I will 100% verify that my shared partition library exists in the APK, but I can not successfully use System.loadLibrary('mylibrary') - and it turns out that this is due to the fact that the dependency lib ++ _ shared.so is missing.
As in, I get the following error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
In my old ndk-build process, I always ended up in two libraries (mylibrary.so and lib ++ _ shared.so) in my output folder, which thus got together in the application. It seems that the CMake toolchain does not bind lib ++ _ shared.so at all (indeed, it was not found in the APK).
I hit my head about it for 6 hours. Can I somehow get the CMake toolchain to merge this missing library? Any clues?
.
.
My settings:
In gradle.build:
externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_shared', '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_PLATFORM=android-16' } }
And my CMakeLists.txt (file names are cut out for brevity):
cmake_minimum_required(VERSION 3.4.1) set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11") include_directories(.) include_directories(./other) set(my_SRCS jniInterface.cpp etc.cpp) add_library(mylibrary SHARED ${my_SRCS}) target_link_libraries(mylibrary atomic log)
Mete source share