图书馆' javacv-android-arm.jar'包含不在设备上运行的本机库

时间:2014-07-16 05:53:37

标签: java android opencv android-ndk google-code

如何解决此问题?

我只是在我的项目Lib文件夹下复制javacv jar文件并出现此错误!

我可以从谷歌找到这个thread,但由于我国的谷歌限制政策,页面无法打开。

我在Android应用程序中包含这些jar的原因是我不想使用openCV manager。我想静态地将openCV库链接到我的项目。我正在尝试在Samsung Galaxy S5上运行我的应用。

以下是我遇到的LogCat错误:

[2014-07-16 10:13:57 - face-recognition] The library 'javacv-android-arm.jar' contains native libraries that will not run on the device.
[2014-07-16 10:13:57 - face-recognition] The following libraries were found:
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniARToolKitPlus.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniavcodec.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniavdevice.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniavfilter.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniavformat.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniavutil.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjnicvkernels.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_calib3d.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_contrib.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_core.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_features2d.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_flann.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_highgui.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_imgproc.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_legacy.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_ml.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_nonfree.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_objdetect.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_photo.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_stitching.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_video.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniopencv_videostab.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjnipostproc.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniswresample.so
[2014-07-16 10:13:57 - face-recognition]  - com/googlecode/javacv/cpp/android-arm/libjniswscale.so

修改-1 在我按照here中的说明操作后,感谢PRAKASH我可以解决这些错误,但我还有其他与NoClassDefFoundError完全相关的错误。我真的放弃了。我无法解决这个问题,所以任何帮助都会非常感激。以下是我的新错误:

07-22 08:48:54.472: E/dalvikvm(11694): Could not find class 'com.googlecode.javacv.cpp.opencv_core$MatVector', referenced from method org.opencv.javacv.facerecognition.PersonRecognizer.train
07-22 08:48:54.472: W/dalvikvm(11694): VFY: unable to resolve new-instance 108 (Lcom/googlecode/javacv/cpp/opencv_core$MatVector;) in Lorg/opencv/javacv/facerecognition/PersonRecognizer;
07-22 08:48:54.472: D/dalvikvm(11694): VFY: replacing opcode 0x22 at 0x001c
07-22 08:48:54.472: D/dalvikvm(11694): DexOpt: unable to opt direct call 0x00c9 at 0x28 in Lorg/opencv/javacv/facerecognition/PersonRecognizer;.train
07-22 08:48:54.472: D/AndroidRuntime(11694): Shutting down VM
07-22 08:48:54.472: W/dalvikvm(11694): threadid=1: thread exiting with uncaught exception (group=0x41737c08)
07-22 08:48:54.477: E/AndroidRuntime(11694): FATAL EXCEPTION: main
07-22 08:48:54.477: E/AndroidRuntime(11694): Process: org.opencv.javacv.facerecognition, PID: 11694
07-22 08:48:54.477: E/AndroidRuntime(11694): java.lang.NoClassDefFoundError: com.googlecode.javacv.cpp.opencv_contrib

2 个答案:

答案 0 :(得分:5)

下载Javacv latest version

并提取并放入 项目的ffmpeg.jar文件夹中的javacv.jarjavacpp.jaropencv.jarlibs

并从提取的

中提取所有* .so
opencv-android-arm.jar,ffmpeg-android-arm.jar files.

并将所有* .so文件放在 libs / armeabi 文件夹中

了解更多信息click here

它可以解决您的问题。

答案 1 :(得分:0)

如果您还没有安装Android开发环境,可以点击此链接,其中包含快速入门所需的一切。观看教程视频并按照下面的说明安装Eclipse,用于Android开发的集成开发环境(IDE)并创建一个新项目。

安装完所有内容并创建项目后,使用以下过程将JavaCV库导入Android项目:

下载JavaCv库: 一个。从此链接下载" javacv-0.7-bin.zip "并提取文件: - javacpp.jar - javacv.jar - javacv-android-arm.jar 湾从此链接下载" javacv-0.7-cppjars.zip"并提取文件: - opencv-2.4.8-android-arm.jar - ffmpeg-2.1.1-android-arm.jar

转到文件>新>文件夹,选择您的项目作为父文件夹,键入" libs / armeabi"作为文件夹名称,然后单击“完成”。

将javacpp.jar和javacv.jar复制到" libs"文件夹中。

将所有* .so文件从javacv-android-arm.jar,opencv-2.4.8-android-arm.jar和ffmpeg-2.1.1-android-arm.jar直接提取到"库/ armeabi"文件夹,不创建在JAR文件中找到的任何子目录。 (从.jar中提取.so文件的最简单方法是使用7-ZIP软件,可以在这里下载)。

导航至项目>属性> Java构建路径>图书馆并点击"添加JAR ..."。

从" libs"中选择javacpp.jar和javacv.jar。文件夹中。

最后,将JavaCV函数导入代码

 import static com.googlecode.javacv.cpp.opencv_core.*;
 import static com.googlecode.javacv.cpp.opencv_imgproc.*;
 import static com.googlecode.javacv.cpp.opencv_highgui.*;

并使用一些示例代码检查一切是否正常。