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.
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:
here is armv8a I had generated https://github.com/2666fff/opencv-for-android
As @Michael already suggested you can rebuild the OpenCV with libc++.
To do it:
NOTE: tested with "opencv-3.4.1" + ndk18
Edited by @shizhen
Verified on macOS, should add
..
aftercmake
command to make below error disappear.Updated as below:
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.