NDK - problems after GNUSTL has been removed from the NDK (revision r18)

As @Michael already suggested you can rebuild the OpenCV with libc++.

To do it:

cd $OPENCV_SRC
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_DIR/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DANDROID_STL=c++_static  -DCMAKE_BUILD_TYPE=Release -DANDROID_NATIVE_API_LEVEL=android-24 ..
make install
cd install #the sdk will be here...

NOTE: tested with "opencv-3.4.1" + ndk18


Edited by @shizhen

Verified on macOS, should add .. after cmake command to make below error disappear.

CMake Error: The source directory "/opencv-3.4.1/build"does not appear to contain CMakeLists.txt.

Updated as below:

cd $OPENCV_SRC
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$ANDROID_DIR/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DANDROID_STL=c++_static  -DCMAKE_BUILD_TYPE=Release -DANDROID_NATIVE_API_LEVEL=android-24 
make install
cd install #the sdk will be here...

It may take a while for OpenCV to be updated. In the meantime, I would recommend to step back f to NDK r16 which was used to build the OpenCV Android binaries.


first reply to @Aqeel iqbal's comment in the first comment, the reason you cannot find a cmakelist is may because you are not using opencv sources, opencv provide independet package for android sdk. The following ling is the origenal source for opencv sources opencv release, choose sources to download, not android pack.

After download the sources, cd to the root dir of the source file e.g. opencv-2.4.13.6 then execute the command provided by @y30, and noted the $ANDROID_DIR may not be your correct file path of your android ndk, for me I use these:

... -DCMAKE_TOOLCHAIN_FILE=/Users/ihandysoft/Library/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake ...

here is armv8a I had generated https://github.com/2666fff/opencv-for-android