【问题标题】:java.lang.UnsatisfiedLinkError: Couldn't load from loader findLibrary returned nulljava.lang.UnsatisfiedLinkError: 无法从加载器 findLibrary 加载返回 null
【发布时间】:2014-10-26 22:39:18
【问题描述】:

我在eclipse中使用NDK。

这是我在 java 中的 NativeLib:

public class NativeLib {

public native String enCode(String src);

static {
    System.loadLibrary("HelloWorld");
}

public native String deCode(String src);
}

这是 C 源代码:

#include <string.h>
#include <jni.h>
#include <stdio.h>

jstring Java_com_example_helloworld_NativeLib_enCode(JNIEnv* env,
    jobject thiz, jstring src) {
...
return (*env)->NewStringUTF(env, result);
}

jstring Java_com_example_helloworld_NativeLib_deCode(JNIEnv* env, jobject thiz,
    jstring src) {
...
return (*env)->NewStringUTF(env, result);
}

我的项目在 android 4.2 中运行正常,但在 android 4.3(Tablet ASUS K012) 中出现如下错误

java.lang.UnsatisfiedLinkError: 无法从加载器 dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.helloworld-2.apk"],nativeLibraryDirectories=[/data 加载 HelloWorld /app-lib/com.example.helloworld-2, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary 返回 null

谁能帮帮我?

【问题讨论】:

  • 这款平板电脑的处理器是什么?你为这个处理器提供了本地库吗?
  • @Selvin 我不明白。我忘记了我将我的图书馆与 vitamio 一起使用。如果我不使用 vitamio 它运行正常。
  • 你是如何解决这个问题的?

标签: java android android-ndk


【解决方案1】:

这可能是因为您没有为所有平台编译本机代码。华硕 K012 正在运行英特尔处理器,这可能是原因。在您的 JNI 文件夹和以下参数中添加一个名为 application.mk 的文件 APP_ABI := 全部

这将为所有平台编译本机部分。

【讨论】:

    猜你喜欢
    • 2015-05-02
    • 1970-01-01
    • 2013-11-05
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多