0

我在android中面临opencv的问题。我在谷歌上尝试了很多搜索,也尝试调试。但无法找出解决方案。这是hte logcat文件:

06-27 16:52:41.423: E/AndroidRuntime(6974): FATAL EXCEPTION: main
06-27 16:52:41.423: E/AndroidRuntime(6974): java.lang.UnsatisfiedLinkError: Couldn't load native_sample: findLibrary returned null
06-27 16:52:41.423: E/AndroidRuntime(6974):     at java.lang.Runtime.loadLibrary(Runtime.java:365)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at java.lang.System.loadLibrary(System.java:535)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at org.opencv.face.Sample3Native$1.onManagerConnected(Sample3Native.java:83)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:314)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1068)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1085)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.os.Handler.handleCallback(Handler.java:605)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.os.Looper.loop(Looper.java:137)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at android.app.ActivityThread.main(ActivityThread.java:4441)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at java.lang.reflect.Method.invokeNative(Native Method)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at java.lang.reflect.Method.invoke(Method.java:511)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
06-27 16:52:41.423: E/AndroidRuntime(6974):     at dalvik.system.NativeStart.main(Native Method)

我可以说问题在于加载 native_sample 库。但是没有任何解决办法。我在以下行中收到错误:

// Load native library after(!) OpenCV initialization
System.loadLibrary("native_sample");

这是我的 android.mk 文件:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include ../../sdk/native/jni/OpenCV.mk

LOCAL_MODULE    := native_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)

这是我的 application.mk 文件:

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi

这是我的控制台输出:

**** Build of configuration Default for project Face Recognition_opencv ****

D:\NDK\android-ndk-r8e-windows-x86\android-ndk-r8e\ndk-build.cmd 
"Compile++ thumb : native_sample <= jni_part.cpp
SharedLibrary  : libnative_sample.so
Install        : libnative_sample.so => libs/armeabi/libnative_sample.so

**** Build Finished ****

而且我的 bin 文件没有生成。那就是我"setContentView(R.layout.activity_main);" 在 "R" 中遇到错误。

4

1 回答 1

1

在您的Android.mk文件中,应该include如下所示:

include $(LOCAL_PATH)/../../sdk/native/jni/OpenCV.mk

您需要将其更改为指向您的实际OpenCV.mk文件(即$(LOCAL_PATH)是您的文件夹的路径jni,并且您需要指向<your OpenCV4Android folder>/sdk/native/jni/OpenCV.mk)。

于 2013-07-01T13:52:59.300 回答