[英]Android - OpenCV error: Cannot load info library for OpenCV
I already setup OpenCV SDK in Android Studio ( https://www.learn2crack.com/2016/03/setup-opencv-sdk-android-studio.html ) but it seems I got this kind of error message.我已经在 Android Studio ( https://www.learn2crack.com/2016/03/setup-opencv-sdk-android-studio.html ) 中设置了 882717118SDK 但似乎我收到了这种错误消息
05-12 03:30:08.819 5480-5480/my.xxxxx I/art: Late-enabling -Xcheck:jni
05-12 03:30:08.925 5480-5480/my.xxxxx D/OpenCV/StaticHelper: Trying to get library list
05-12 03:30:08.926 5480-5480/my.xxxxx E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
05-12 03:30:08.926 5480-5480/my.xxxxx D/OpenCV/StaticHelper: Library list: ""
05-12 03:30:08.926 5480-5480/my.xxxxx D/OpenCV/StaticHelper: First attempt to load libs
05-12 03:30:08.926 5480-5480/my.xxxxx D/OpenCV/StaticHelper: Trying to init OpenCV libs
05-12 03:30:08.926 5480-5480/my.xxxxx D/OpenCV/StaticHelper: Trying to load library opencv_java3
05-12 03:30:08.926 5480-5480/my.xxxxx D/OpenCV/StaticHelper: Cannot load library "opencv_java3"
I already include opencv_java3
into JNI
folder.我已经将
opencv_java3
包含到JNI
文件夹中。
If someone is still (March 2020) searching for this error -如果有人仍在(2020 年 3 月)搜索此错误 -
E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
and ends up here on this StackOverflow discussion, here is a helpful clarification from the OpenCV contributor on their site itself.并在此 StackOverflow 讨论中结束,这里是 OpenCV 贡献者在其网站上的有用说明。
Ignore this error message.
忽略此错误消息。 "Info library" is used for special Android configurations, like builds with CUDA support.
“信息库”用于特殊的 Android 配置,例如支持 CUDA 的构建。
Please see this (currently open) issue here - https://github.com/opencv/opencv/issues/15567请在此处查看此(当前打开的)问题 - https://github.com/opencv/opencv/issues/15567
Most online tutorial will tell you to add just armeabi-v7a
and x86_64
into your jniLibs
folder, but this can cause errors in recent versions of OpenCV.大多数在线教程会告诉您只将
armeabi-v7a
和x86_64
添加到jniLibs
文件夹中,但这可能会导致最新版本的 OpenCV 出现错误。 The following briefly describes a few tweaks I used to fix this error when I was experiencing the same issue.下面简要描述了我在遇到相同问题时用来修复此错误的一些调整。
Solution 1:解决方案1:
Make sure the JNI folder you are placing the OpenCV libraries in is named jniLibs
确保您放置 OpenCV 库的 JNI 文件夹名为
jniLibs
Solution 2:解决方案2:
Copy ALL the directories found in OpenCV-android-skd/sdk/native/libs
to your jniLibs
folder.将在
OpenCV-android-skd/sdk/native/libs
找到的所有目录复制到jniLibs
文件夹。
jniLibs folder with all OpenCV libraries added添加了所有 OpenCV 库的 jniLibs 文件夹
Recommended:推荐:
Even though it is a separate issue involving the emulator, you should also add the code snippet posted by FD3 in your app Module Gradle file.即使它是一个涉及模拟器的单独问题,您也应该在您的应用程序模块 Gradle 文件中添加FD3发布的代码片段。 This will prevent the INSTALL_FAILED_NO_MATCHING_ABIS error from occuring after attempting to run your app on an emulator.
这将防止在尝试在模拟器上运行您的应用程序后发生INSTALL_FAILED_NO_MATCHING_ABIS错误。
Over a year later but I found this to work for me.一年多后,但我发现这对我有用。 In you app Module gradle file, add:
在你的 app 模块 gradle 文件中,添加:
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'x86_64'
universalApk true
}
}
This should be put in with the android brackets.这应该与android括号一起放入。 Obviously adjust your includes for which ever you may need.
显然,根据您的需要调整您的包含。
possibly missing libc++_shared.so library that comes with the Android NDK as explained in https://stackoverflow.com/a/66692717/14019579 .可能缺少 Android NDK 附带的libc++_shared.so库,如https://stackoverflow.com/a/66692717/14019579 中所述。
Solution解决方案
doing this after the first link worked on Studio V4.2.1 and OpenCV 4.5.2在第一个链接适用于 Studio V4.2.1 和 OpenCV 4.5.2 之后执行此操作
Is it necessary to use OpenCV 3.0?是否有必要使用 OpenCV 3.0? The latest OpenCV SDK is easy to install.
最新的 OpenCV SDK 易于安装。 It does not require to pre-compile the SDK.
不需要预编译SDK。 It uses CMake to link to the SDK.
它使用 CMake 链接到 SDK。 You can download it on this website: https://opencv.org/releases/
你可以在这个网站上下载: https : //opencv.org/releases/
I will try to go through how to import openCV in android studio.我将尝试了解如何在 android studio 中导入 openCV。
First, you have to create a JNI project.首先,您必须创建一个 JNI 项目。 As you know, OpenCV is a C++ library.
如您所知,OpenCV 是一个 C++ 库。
Then, import the SDK, File > New > Import Module…然后,导入 SDK,文件 > 新建 > 导入模块...
And choose the “sdk” folder in the OpenCV SDK.并选择 OpenCV SDK 中的“sdk”文件夹。
Open setting.gradle, add this code to tell the project you have a opencv module.打开setting.gradle,添加这段代码告诉项目你有一个opencv模块。
include "opencv"
project(":opencv").projectDir = file("sdk")
arguments "-DOpenCV_DIR=" + file('../sdk').absolutePath + "/native/jni",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_STL=c++_shared"
dependences {
...
implementation project(':opencv')
}
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "")
message(STATUS "ANDROID_ABI=${ANDROID_ABI}")
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS})
target_link_libraries(${PROJECT_NAME} ${ANDROID_OPENCV_COMPONENTS})
You can find a detailed tutorial with pictures at this link: https://kcwong-joe.medium.com/how-to-import-opencv-4-5-2-in-android-studio-d9114179628f您可以在此链接中找到带图片的详细教程: https : //kcwong-joe.medium.com/how-to-import-opencv-4-5-2-in-android-studio-d9114179628f
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.