Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

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

Today I updated my Android Studio NDK to the most recent release 18.0.5002713. After the successful installation process I tried to rerun my app but was not able to do so. The error that keeps appearing is the following: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.

In the past I've already had problems running my app after NDK updates but was able to resolve them by adding arguments '-DANDROID_STL=gnustl_static' to the externalNativeBuild configuration in the app.gradle file.

Original question: (OpenCV - undefined reference to 'cv::CascadeClassifier::detectMultiScale() after NDK update)

By adding this line of code I managed to avoid any sort of problem with the NDK throughout the rest of all NDK r17c releases.

Unfortunately with revision r18 the support for GNUSTL has been removed alongside gabi++ and stlport.

See NDK revision history: https://developer.android.com/ndk/downloads/revision_history

Removing the now deprecated line of code produces the error that originally was the reason for the aforementioned question. The question now is what is the up-to-date equivalent of arguments '-DANDROID_STL=gnustl_static'?

edit: using '-DANDROID_STL=c++_static' leads to the old error

Thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...