Reputation: 13
While using OpenCV library I am getting the error:
Error:Execution failed for task ':app:compileDebugNdk'. Error: Your project contains C++ files but it is not using a supported native build system. Consider using CMake or ndk-build integration with the stable Android Gradle plugin: https://developer.android.com/studio/projects/add-native-code.html or use the experimental plugin: http://tools.android.com/tech-docs/new-build-system/gradle-experimental.`
When i created the jniLibs
folder then it shows me the cpp folder and not when i run the app it shows that i have cpp files but they are not using a supprted native build system
Upvotes: 1
Views: 363
Reputation: 10519
I was able to build opencv from git (https://github.com/opencv/opencv/tree/3.1.0) using the NDK's cmake yesterday.
export ANDROID_NDK=~/android-sdks/ndk-bundle
cmake -GNinja -DANDROID_TOOLCHAIN_NAME=clang -DANDROID_ABI=armeabi-v7a \
-DANDROID_ARM_NEON=ON -DENABLE_NEON=ON -DANDROID_STL=c++_static \
-DANDROID_CPP_FEATURES="rtti exceptions" -DANDROID_PLATFORM=android-9 \
-DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_FAT_JAVA_LIB=OFF \
-DBUILD_JASPER=OFF -DBUILD_OPENEXR=OFF -DBUILD_PACKAGE=OFF \
-DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_TIFF=ON \
-DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_java=OFF \
-DBUILD_opencv_python2=OFF -DBUILD_opencv_world=OFF \
-DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all" \
-DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all -fvisibility-inlines-hidden" \
-DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_EIGEN=OFF -DWITH_JASPER=OFF \
-DWITH_OPENEXR=OFF -DWITH_TIFF=ON -DWITH_TBB=ON -DWITH_CUDA=OFF \
-DWITH_CUFFT=OFF -DWITH_WEBP=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
path/to/opencv
That's command line use, but something similar should work if you're building from within Android Studio. I'm guessing you don't need all those options, but those were the instructions given to me.
Unfortunately there's a bug in the NDK r13 cmake toolchain that needed to be fixed first: https://github.com/android-ndk/ndk/issues/234. We're about to publish the first beta for NDK r14 which does have the fix. You shouldn't use the betas for production, but if you're not planning to ship right away it should reach stable release in February.
Upvotes: 1
Reputation: 13353
Try download latest OpenCV SDK from here and add it to your project by steps, described by @ssimm here
Upvotes: 0