阅读背景:

. lang。不满足链接错误:无法从加载程序加载native_sample。

来源:互联网 

The errors:

错误:

Process: com.example.syafiq.opencvoi, PID: 7760
java.lang.UnsatisfiedLinkError: Couldn't load native_sample from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.syafiq.opencvoi-13.apk,libraryPath=/data/app-lib/com.example.syafiq.opencvoi-13]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.example.syafiq.opencvoi.Sample3Native

The errors:

错误:

Process: com.example.syafiq.opencvoi, PID: 7760
java.lang.UnsatisfiedLinkError: Couldn't load native_sample from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.syafiq.opencvoi-13.apk,libraryPath=/data/app-lib/com.example.syafiq.opencvoi-13]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.example.syafiq.opencvoi.Sample3Native$1.onManagerConnected(Sample3Native.java:79)
at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

The sample3Native.java line 79 were:

sample3Native。java 79行:

 public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");

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

And the AsyncServiceHelper.Java line 319 were

和AsyncServiceHelper。Java第319行

mUserAppCallback.onManagerConnected(status);

Android.mk

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)

And application.mk

和application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi armeabi-v7a
LOCAL_ARM_NEON := true

There's no errors in the codes. I've tried several solution but yet the result are still the same, The codes was obtained from open source website. I'm not good enough with android studio, and I'm still learning. I hope you guys can help me to solve this error. I really appreciate your help and consideration to help me and solve my error. I appreciate your time :)

代码中没有错误。我已经尝试了几种解决方案,但结果仍然是一样的,代码是从开源网站获得的。我对android studio不够好,我还在学习。我希望你们能帮我解决这个错误。我非常感谢你的帮助和考虑,帮助我解决我的错误。谢谢你的时间

2 个解决方案

#1


0  

From my perspective something wrong with versions of your "native_sample" library. As it's written in documentation

从我的角度来看,您的“native_sample”库的版本有问题。正如它在文档中所写。

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.

如果Java虚拟机无法找到声明为本机的方法的本机语言定义,则抛出。

It's possible that there are both versions in your classpath, and jvm loads wrong version. So it finds library but during class-loading process find inconsistency, probably required method was added in later lib version.

在您的类路径中可能有两个版本,而jvm装载错误的版本。所以它找到了库,但是在类加载过程中发现不一致,可能需要在以后的lib版本中添加方法。

I suggest trying this:

我建议尝试:

System.load(String path) //with an absolute path to needed lib

Also see: Difference between System.load() and System.loadLibrary in Java

也可以看到:System.load()和系统之间的区别。loadLibrary在Java中

#2


0  

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.syafiq.opencvoi"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {

           // jniLibs.srcDirs = ['libs']
       main{
         jniLibs{
           srcDir 'libs'
         }
       }

    }


}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile project(':libraries:opencv')
}

.onManagerConnected(Sample3Native.java:79) at org.opencv.android.AsyncServiceHelper.onServiceConnected(AsyncServiceHelper.java:319) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Process: com.example.syafiq



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: