Error: OpenCV is considered to be Not Found

I got the following errors:

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error at C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt:11 (find_package):
Found package configuration file:

C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake

but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be
NOT FOUND.

For more details, see my repo: https://github.com/pstricks-fans/nativeopencvtest/blob/master/app/src/main/cpp/CMakeLists.txt

Other configurations:

envi

The contents of C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:



if(CMAKE_VERSION VERSION_LESS "2.8.3")
  get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
endif()

if(NOT DEFINED OpenCV_CONFIG_SUBDIR)
  set(OpenCV_CONFIG_SUBDIR "/abi-${ANDROID_NDK_ABI_NAME}")
endif()

set(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}${OpenCV_CONFIG_SUBDIR}")
if(EXISTS "${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
  include("${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
else()
  if(NOT OpenCV_FIND_QUIETLY)
    message(WARNING "Found OpenCV Android Pack but it has no binaries compatible with your ABI (can't find: ${OpenCV_CONFIG_SUBDIR})")
  endif()
  set(OpenCV_FOUND FALSE)
endif()

If I comment the second line from the bottom:

  endif()
  # set(OpenCV_FOUND FALSE)
endif()

The build is successful with the following messages:

Executing tasks: [:app:assembleDebug] in project C:\Users\amd\Documents\OpenNative

Task :app:preBuild UP-TO-DATE
Task :app:preDebugBuild UP-TO-DATE
Task :app:compileDebugAidl NO-SOURCE
Task :app:compileDebugRenderscript NO-SOURCE
Task :app:generateDebugBuildConfig UP-TO-DATE
Task :app:javaPreCompileDebug UP-TO-DATE
Task :app:checkDebugAarMetadata UP-TO-DATE
Task :app:generateDebugResValues UP-TO-DATE
Task :app:generateDebugResources UP-TO-DATE
Task :app:mergeDebugResources UP-TO-DATE
Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
Task :app:extractDeepLinksDebug UP-TO-DATE
Task :app:processDebugMainManifest UP-TO-DATE
Task :app:processDebugManifest UP-TO-DATE
Task :app:processDebugManifestForPackage UP-TO-DATE
Task :app:processDebugResources UP-TO-DATE
Task :app:compileDebugJavaWithJavac UP-TO-DATE

Task :app:generateJsonModelDebug
C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|x86 : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|x86 : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|x86_64 : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

C:\Users\amd\Documents\OpenNative\app\src\main\cpp\CMakeLists.txt : C/C++ debug|x86_64 : CMake Warning at C:/opencv-4.5.2-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):
Found OpenCV Android Pack but it has no binaries compatible with your ABI
(can’t find: /abi-)
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

Task :app:externalNativeBuildDebug
Build native-lib_armeabi-v7a
ninja: Entering directory C:\Users\amd\Documents\OpenNative\app\.cxx\cmake\debug\armeabi-v7a' ninja: no work to do. Build native-lib_arm64-v8a ninja: Entering directory C:\Users\amd\Documents\OpenNative\app.cxx\cmake\debug\arm64-v8a’
ninja: no work to do.
Build native-lib_x86
ninja: Entering directory C:\Users\amd\Documents\OpenNative\app\.cxx\cmake\debug\x86' ninja: no work to do. Build native-lib_x86_64 ninja: Entering directory C:\Users\amd\Documents\OpenNative\app.cxx\cmake\debug\x86_64’
ninja: no work to do.

Task :app:compileDebugSources
Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
Task :app:mergeDebugShaders UP-TO-DATE
Task :app:compileDebugShaders NO-SOURCE
Task :app:generateDebugAssets UP-TO-DATE
Task :app:mergeDebugAssets UP-TO-DATE
Task :app:compressDebugAssets UP-TO-DATE
Task :app:processDebugJavaRes NO-SOURCE
Task :app:mergeDebugJavaResource UP-TO-DATE
Task :app:checkDebugDuplicateClasses UP-TO-DATE
Task :app:dexBuilderDebug UP-TO-DATE
Task :app:desugarDebugFileDependencies UP-TO-DATE
Task :app:mergeExtDexDebug UP-TO-DATE
Task :app:mergeDexDebug UP-TO-DATE
Task :app:mergeDebugJniLibFolders UP-TO-DATE
Task :app:mergeDebugNativeLibs UP-TO-DATE
Task :app:stripDebugDebugSymbols UP-TO-DATE
Task :app:validateSigningDebug UP-TO-DATE
Task :app:packageDebug UP-TO-DATE
Task :app:assembleDebug

BUILD SUCCESSFUL in 4s
28 actionable tasks: 2 executed, 26 up-to-date

Build Analyzer results available

What is the correct way to fix this issue?

OpenNative

so you are using that library.

you should seek support from them, not from OpenCV.

OpenNative is the name of my application. It is a trivial project name. I can change it to XYZ.

I see.

well, if it says OpenCV_FOUND is false, this is what would be causing it:

if(EXISTS "${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
  include("${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
else()
  ...
  set(OpenCV_FOUND FALSE)
endif()

so… that path wasn’t given, it was given but wrong, or that file doesn’t exist there.

note that that path isn’t jni/OpenCVConfig.cmake but but seems to be a file in “regular” OpenCV. it should exist in the build dir or install dir of opencv.

I found the culprit. I changed the minSDKVersion in my_opencv_sdk_path\sdk\build.gradle from its original value of 21 to 19 because I wanted to match against my project minSDKVersion of 19 (I wanted to support more legacy devices).

But now because of this problem, I set my project minSDKVersion to 21 and return the OpenCV minSDKVersion back to 21. Everything goes well without problem.

1 Like