我与一个非常烦人的问题作斗争。我有一个使用适用于 Android 的 OpenCV 库的应用程序。问题是它抛出了以下异常:
12-07 14:19:27.420: E/AndroidRuntime(19108): FATAL EXCEPTION: main
12-07 14:19:27.420: E/AndroidRuntime(19108): java.lang.UnsatisfiedLinkError: Couldn't load libopencv_java.so from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.elsys.coursework.smartcam-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.elsys.coursework.smartcam-2, /vendor/lib, /system/lib]]]: findLibrary returned null
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.Runtime.loadLibrary(Runtime.java:355)
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.System.loadLibrary(System.java:525)
12-07 14:19:27.420: E/AndroidRuntime(19108): at org.elsys.coursework.smartcam.MainActivity.<clinit>(MainActivity.java:110)
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.Class.newInstanceImpl(Native Method)
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.Class.newInstance(Class.java:1130)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.ActivityThread.access$600(ActivityThread.java:149)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.os.Looper.loop(Looper.java:137)
12-07 14:19:27.420: E/AndroidRuntime(19108): at android.app.ActivityThread.main(ActivityThread.java:5214)
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 14:19:27.420: E/AndroidRuntime(19108): at java.lang.reflect.Method.invoke(Method.java:525)
12-07 14:19:27.420: E/AndroidRuntime(19108): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
12-07 14:19:27.420: E/AndroidRuntime(19108): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
12-07 14:19:27.420: E/AndroidRuntime(19108): at dalvik.system.NativeStart.main(Native Method)
我搜索了解决方案,但没有任何效果。我尝试手动将 libopencv_java.so 添加到 libs/armeabi-v7a 文件夹中,但每次添加时,eclipse 都会自动将其删除。
以下是 mk 文件:
安卓.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include /home/crash-id/Development/SDK/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := orbdetector
LOCAL_SRC_FILES := ORBDetector.cpp
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
应用程序.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16