Ask Your Question
0

getting unsatisfiedLinkerror while trying to re-use opencv-facedection sample

asked 2013-10-27 14:14:47 -0500

bunta gravatar image

updated 2013-10-27 14:42:50 -0500

I am trying to use openCV in android. So I am following the link - http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

My basic intenstion is to create my own Android project and copying all the OpenCV Sample - face-detection sample source code to the new project and test the same to verify the android project setup.

I created an android project XYZ and then added the openCV library, then copied the jni directory from OpenCV Sample - face-detection to XYZ project and then trigger http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_dev_intro.html#cdt-builder

which generate a armeabi-v7a directory inside lib folder. Then I copied all the sourcecode from sample to xyz and run and then I found the following error-

java.lang.UnsatisfiedLinkError: Native method not found:

com.example.emotiondetector.DetectionBasedTracker.nativeCreateObject:(Ljava/lang/String;I) at com.example.emotiondetector.DetectionBasedTracker.nativeCreateObject(Native Method)

at com.example.emotiondetector.DetectionBasedTracker.<init> com.example.emotiondetector.FdView.<init>(FdView.java:146)

Means jni didnt work properly. Can anyone suggest where did I miss the core thing ?

Following warning came while generating jni-

C:\android-ndk-r9-windows-x86_64\android-ndk-r9\ndk-build.cmd Android NDK: WARNING:jni/Android.mk:detection_based_tracker: non-system libraries in linker flags: -lopencv_java Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the Android NDK:
current module Install : libdetection_based_tracker.so => libs/armeabi-v7a/libdetection_based_tracker.so

AFter quick search I found its a popular problem-

"java.lang.UnsatisfiedLinkError: Native method not found: com.test.camera.DetectionBasedTracker.nativeCreateObject:(Ljava/lang/String;I)J", FdView.java ->

But couldnt get any solution ...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-08-24 23:24:23 -0500

pprov gravatar image

updated 2014-08-24 23:26:44 -0500

If you copied the .h and .cpp from the face-detection sample to your own project, be sure to update the function signatures to reflect your own Java package rather than the OpenCV one. Look for something like this:

Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject

and change it to:

Java_com_your_app_DetectionBasedTracker_nativeCreateObject

where com_your_app is your android project's Java package name

This needs to be done for all the functions in the .h and .cpp files. (Alternatively, look into the use of javah)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-10-27 14:14:47 -0500

Seen: 1,721 times

Last updated: Aug 24 '14