的UnsatisfiedLinkError:...:findLibrary返回NULL [英] UnsatisfiedLinkError: ... :findLibrary returned null

查看:215
本文介绍了的UnsatisfiedLinkError:...:findLibrary返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  03-01 14:00:53.556:E / AndroidRuntime(27208):java.lang.UnsatisfiedLinkError中:无法加载
例如,从装载机dalvik.system.PathClassLoader [DexPathList [zip文件
/data/app/com.example.test-2.apk\"],nativeLibraryDirectories=[/data/app-lib/com.example.test-
2,/供应商/ lib中/系统/ lib目录]]]:findLibrary返回NULL

我想获得设立的Andr​​oid NDK开发在Ubuntu 12一个基本的环境,我不能让这个错误消失。我的系统已经建立了与SDK普通Android开发。我已经安装了Eclipse的C / C ++开发工具。

我的.bashrc中有以下线在底部:

  NDK_HOME =〜/ Android的NDK-R9C
出口NDK_HOME
出口PATH = /家庭/史蒂夫/ Android的NDK-R9C:$ {PATH}
出口NDK_PATH = /家庭/史蒂夫/ Android的NDK-R9C

在我的Eclipse特性,Android-我NDK的位置> NDK设置为/ home /史蒂夫/ Android的NDK-R9C。我Android.mk看起来如下:

  LOCAL_PATH:= $(叫我-DIR)包括$(CLEAR_VARS)LOCAL_MODULE:=测试
LOCAL_SRC_FILES:= example.c包括$(BUILD_SHARED_LIBRARY)

我试着使用编译NDK在命令行上。我现在已经在我的项目目录中的文件OBJ /本地/ armeabi / libtest.so,但它没有做任何我很好。

有关它的价值,没有项目的工作,甚至没有NDK样本工程(如HelloJni)。我能做些什么来编译一个基本的JNI应用程序?

编辑:这是一个实际的设备上。 HELLO-JNI的NDK的构建输出是:

  [armeabi-V7A] GDBSERVER:[臂Linux的androideabi-4.6]库/ armeabi-V7A / gdbserver的
[armeabi-V7A] Gdbsetup:林达/ armeabi-V7A / gdb.setup
[armeabi] GDBSERVER:[臂Linux的androideabi-4.6]库/ armeabi / gdbserver的
[armeabi] Gdbsetup:林达/ armeabi / gdb.setup
[86] GDBSERVER:[x86-4.6]林达/ 86 / gdbserver的
[86] Gdbsetup:林达/ 86 / gdb.setup
[MIPS] GDBSERVER:[mipsel体系-Linux的Andr​​oid平台的4.6]库/ MIPS / gdbserver的
[MIPS] Gdbsetup:林达/ MIPS / gdb.setup
[armeabi-V7A]编译大拇指:HELLO-JNI< = HELLO-jni.c
[armeabi-V7A] SharedLibrary:libhello-jni.so
[armeabi-V7A]安装:libhello-jni.so =>库/ armeabi-V7A / libhello-jni.so
[armeabi]编译大拇指:HELLO-JNI< = HELLO-jni.c
[armeabi] SharedLibrary:libhello-jni.so
[armeabi]安装:libhello-jni.so =>库/ armeabi / libhello-jni.so
[86]编译:HELLO-JNI< = HELLO-jni.c
[86] SharedLibrary:libhello-jni.so
[86]安装:libhello-jni.so =>库/ 86 / libhello-jni.so
[MIPS]编译:HELLO-JNI< = HELLO-jni.c
[MIPS] SharedLibrary:libhello-jni.so
[MIPS]安装:libhello-jni.so =>库/ MIPS / libhello-jni.so


解决方案

加载共享库的正确的方法是

 静态{
    的System.loadLibrary(测试);
}

库名是从你的Andr​​oid.mk文件的 LOCAL_MODULE 定义取(或从Application.mk文件,如果你决定使用它)。在你的情况,你命名你的模块的测试即可。在 NDK的构建生成共享库 libtest.so

注重,你并不需要包括的 LIB - 的preFIX在的System.loadLibrary()呼叫

03-01 14:00:53.556: E/AndroidRuntime(27208): java.lang.UnsatisfiedLinkError: Couldn't load
example from loader dalvik.system.PathClassLoader[DexPathList[[zip file 
"/data/app/com.example.test-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.test-
2, /vendor/lib, /system/lib]]]: findLibrary returned null

I am trying to get a basic environment set up for Android NDK development on Ubuntu 12 and I cannot get this error to go away. My system is already set up for regular Android development with the SDK. I've installed the eclipse C/C++ development tools.

My .bashrc has these lines at the bottom:

NDK_HOME=~/android-ndk-r9c
export NDK_HOME
export PATH=/home/steve/android-ndk-r9c:${PATH}
export NDK_PATH=/home/steve/android-ndk-r9c

In my Eclipse properties, my NDK location in Android->NDK is set to /home/steve/android-ndk-r9c. My Android.mk looks as follows:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := test
LOCAL_SRC_FILES := example.c

include $(BUILD_SHARED_LIBRARY)

I tried using build-ndk on the command line. I now have in my project directory a file obj/local/armeabi/libtest.so, but it's not doing me any good.

For what it's worth, no project works, not even the NDK sample projects (such as HelloJni). What can I do to compile a basic JNI application?

EDIT: This is on an actual device. The ndk-build output of hello-jni is:

[armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
[armeabi] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[x86] Gdbserver      : [x86-4.6] libs/x86/gdbserver
[x86] Gdbsetup       : libs/x86/gdb.setup
[mips] Gdbserver      : [mipsel-linux-android-4.6] libs/mips/gdbserver
[mips] Gdbsetup       : libs/mips/gdb.setup
[armeabi-v7a] Compile thumb  : hello-jni <= hello-jni.c
[armeabi-v7a] SharedLibrary  : libhello-jni.so
[armeabi-v7a] Install        : libhello-jni.so => libs/armeabi-v7a/libhello-jni.so
[armeabi] Compile thumb  : hello-jni <= hello-jni.c
[armeabi] SharedLibrary  : libhello-jni.so
[armeabi] Install        : libhello-jni.so => libs/armeabi/libhello-jni.so
[x86] Compile        : hello-jni <= hello-jni.c
[x86] SharedLibrary  : libhello-jni.so
[x86] Install        : libhello-jni.so => libs/x86/libhello-jni.so
[mips] Compile        : hello-jni <= hello-jni.c
[mips] SharedLibrary  : libhello-jni.so
[mips] Install        : libhello-jni.so => libs/mips/libhello-jni.so

解决方案

The right way of loading the shared library is

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

The library name is taken from the LOCAL_MODULE definition of your Android.mk file (or from the Application.mk file, if you decide to use it). In your case, you are naming your module test. The ndk-build generates the shared library libtest.so.

Pay attention that you do not need to include the lib- prefix in the System.loadLibrary() call.

这篇关于的UnsatisfiedLinkError:...:findLibrary返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆