6

How can I resolve this issue?

I've just copy javacv jar files under my project Lib folder and got this error!

I can find this thread from google but the page can not be opened because of google restrictions policy in my country unfortunately.

The reason I include these jars in my android application is that I do not want to use openCV manager. I want to statically link openCV library to my project. I am trying to run my app on Samsung Galaxy S5.

Here is the LogCat errors I've got:

[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

EDIT-1 After I follow the instruction in here, thanks to PRAKASH I could resolve these errors, but I have got other errors which are totally related to NoClassDefFoundError. I really give up. I can not resolve the issue, so any help would be really appreciated. Here are my new errors:

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
Community
  • 1
  • 1
A23149577
  • 2,045
  • 2
  • 40
  • 74

2 Answers2

5

download Javacv latest version

and extract it and put ffmpeg.jar ,javacv.jar ,javacpp.jar and opencv.jar in libs folder of your project

and also extract all *.so from extracted

opencv-android-arm.jar,ffmpeg-android-arm.jar files.

and put all *.so files inside libs/armeabi folder

for more information click here

it may solve your problem .

Mr X
  • 1,053
  • 2
  • 11
  • 24
  • exactly, and you should also add `*.so` files extracted from the other `*-android-*.jar` files to your other libs folders, like `opencv-android-x86.jar` to **libs/x86**. If you're using Android Studio/gradle, these directories (armeabi, x86...) are to be created under **jniLibs** instead of **libs**. – ph0b Jul 17 '14 at 08:09
  • Ok, thanks to PRAKASH and @ph0b, I will try this solution and let you guys know about the result – A23149577 Jul 20 '14 at 03:48
  • Ok, I have done every steps you mentioned exactly. Now I have got link error on **com.googlecode.javacv.cpp.opencv_contrib**, Eclipse can not resolve it to type :(. I have got this error on every other **com.googlecode.javacv.cpp.*** libraries which I import :( – A23149577 Jul 22 '14 at 03:53
  • change imported Package name to org.bytedeco.javacv.cpp.*; – Mr X Jul 22 '14 at 04:36
  • changed it, but this package is not resolved too.@PRAKASHUBHADIYA – A23149577 Jul 22 '14 at 04:50
  • which version are you using? – Mr X Jul 22 '14 at 04:52
  • javacv0.8, the link you gave in your answer@PRAKASHUBHADIYA – A23149577 Jul 22 '14 at 04:58
  • Thank you very much, all tutorials are out of date and have some errors, this works even with the latest version 0.11! thanks – Hossein Amini Apr 24 '15 at 09:06
  • what a lol... subfolder makes the trick, but i would have never thought about it :) – keybee Jun 19 '15 at 11:52
0

If you haven't yet installed the Android Development Environment, you can follow this link which contains everything you need to get started quickly. Watch the tutorial video and follow the instructions underneath to install Eclipse, the Integrated Development Environment (IDE) for Android development and create a new project.

Once you have installed everything and have created the project, use the following procedure to import JavaCV libraries to the Android project:

Download the JavaCv libraries: a. From this link download "javacv-0.7-bin.zip " and extract the files: - javacpp.jar - javacv.jar - javacv-android-arm.jar b. From this link download "javacv-0.7-cppjars.zip" and extract the files: - opencv-2.4.8-android-arm.jar - ffmpeg-2.1.1-android-arm.jar

Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish.

Copy javacpp.jar and javacv.jar into the "libs" folder.

Extract all the *.so files from javacv-android-arm.jar, opencv-2.4.8-android-arm.jar, and ffmpeg-2.1.1-android-arm.jar directly into the "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files. (The easiest way to extract the .so files from the .jar is by using 7-ZIP software which can be downloaded here).

Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...".

Select both javacpp.jar and javacv.jar from the "libs" folder.

Finally,import JavaCV functions to your code

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

and use some sample code to check that everything is working correctly.

Elton da Costa
  • 1,279
  • 16
  • 27