最近我开始研究 OpenCV 项目,所以关于这一切的一切对我来说都是新的。我下载了opencv 2.4.11,将其作为模块导入到项目中,添加了模块依赖,将所有libs floder从我的解压缩的opencv目录(.. \ OpenCV-android-sdk \ sdk \ native \ libs)复制到src / main / jniLibs文件夹
当我运行应用程序时,它要求nonfree.so所以我下载了这个文件并添加到jniLibs / armeabi-v7a文件夹但是在libnonfree.so文件被自动删除之后。请帮我解决一下这个。在此先感谢!
Android.mk文件
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include ..\..\OpenCV-android-sdk\sdk\native\jni\OpenCV.mk
LOCAL_CFLAGS := -DOPEL_ES_1 -DANDROID_NDK
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ObjRecog
LOCAL_MODULE := cvgl
LOCAL_SRC_FILES := ObjRecog/commonCvFunctions.cpp ObjRecog/orException.cpp ObjRecog/imageDB.cpp ObjRecog/visualWords.cpp ObjRecog/controlOR.cpp register_natives.cpp native_main.cpp
LOCAL_LDLIBS += -L$(LOCAL_PATH)/lib -lGLESv1_CM -llog -ldl -lnonfree
include $(BUILD_SHARED_LIBRARY)
gradle这个
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/jniLibs'
}
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build.cmd",
'NDK_PROJECT_PATH=build/intermediates/ndk',
'NDK_LIBS_OUT=src/main/jniLibs',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
//end
错误日志
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-support-annotations-23.3.0_a297da53fbdcec7680dd139a0356773a5145040e-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-internal_impl-23.3.0_b1438fdbbcfae5457fd54013dc7fa1db7dc5f100-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.3.0_1d3906f90dad49592f78f3fbd6a6e3e2e8cfe83e-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-com.android.support-support-v4-23.3.0_f0e4c204a57d7f21378a9efa326195ab1a27c0fa-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.3.0_f706f6a782139815e9b350eccc6c4d589212a2dd-classes.dex", dex file "/data/data/meiroo.cvgl/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.3.0_2ab73689fd5f8292318143c69f573864f940d24a-classes.dex"],nativeLibraryDirectories=[/data/app/meiroo.cvgl-1/lib/arm, /vendor/lib, /system/lib, /vendor/lib, /system/lib]]] couldn't find "libnonfree.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:988)
at meiroo.cvgl.CVGLActivity.<clinit>(CVGLActivity.java:56)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1606)
at android.app.Instrumentation.newActivity(Instrumentation.java:1089)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2240)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
CVGLActivity.class 的System.loadLibrary( “非自由”); //第56行