无法在Android应用程序运行时加载库 [英] unable to load library at runtime in android application

查看:550
本文介绍了无法在Android应用程序运行时加载库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米在其中我用JNI的本机C code android应用工作。
我建立在Android 2.0的版本,ndkr3这个应用程序,它工作正常。

现在,当我改变了Android SDK 1.5版和API版本3我面对的无法打开库libtest_demo.so。问题

  05-13 16:54:23.603:信息/ dalvikvm(1211):无法使用dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so):找不到库

我把libtest_demo.so文件在同一个地方/data/data/org.abc.test_demo/lib/libtest_demo.so但还是同样的问题出现了。

在我的java文件我叫本机库一样,

 的System.loadLibrary(abc_jni);
 的System.loadLibrary(test_demo);

和从logcat的我看到这两个库使用相同的内存地址。

这是logcat的输出

  05-13 17:56:15.732:DEBUG / dalvikvm(9897):试图加载的lib /data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.732:DEBUG / dalvikvm(9897):增加了共享库/data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.742:DEBUG / dalvikvm(9897):试图加载的lib /data/data/org.abc.test_demo/lib/libtest_demo.so 0x437317f8
05-13 17:56:15.752:信息/ dalvikvm(9897):无法使用dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so):找不到库


解决方案

这个错误几乎总是说找不到库,并可以有很多原因。什么是恼人的是,在大多数情况下,它是不缺少的库,但别的东西。原因我也偶然发现:


  • 库从目录(明显),
  • 失踪
  • 是动态与库链接库丢失,

  • 系统库的版本上的设备/仿真器,你的库使用与那些你在编译时链接到的不同(缺符号等)

我所描述的,解决与正在对模拟器精细库的问题时,并未能在Nexus One上加载为我工作的方法,也许这将帮助您:<一href=\"http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html\">http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html

I m working on android application in which I used JNI for native c code. I build this application on android 2.0 version and ndkr3 and it works fine.

Now when I changed the android sdk version 1.5 and api version 3 I faced problems of unable to open library libtest_demo.so.

05-13 16:54:23.603: INFO/dalvikvm(1211): Unable to dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so): Cannot find library

I put the libtest_demo.so file at the same place /data/data/org.abc.test_demo/lib/libtest_demo.so but still the same problem arises.

In my java file I called native libraries like,

 System.loadLibrary("abc_jni");
 System.loadLibrary("test_demo");

And from the logcat I seen both libraries used same memory address.

This is logcat output

05-13 17:56:15.732: DEBUG/dalvikvm(9897): Trying to load lib /data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.732: DEBUG/dalvikvm(9897): Added shared lib /data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.742: DEBUG/dalvikvm(9897): Trying to load lib /data/data/org.abc.test_demo/lib/libtest_demo.so 0x437317f8 
05-13 17:56:15.752: INFO/dalvikvm(9897): Unable to dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so): Cannot find library

解决方案

This error almost always says "Cannot find library" and there can be many reasons for this. What is annoying is that in most cases it is not the missing library but something else. Reasons I have stumbled upon:

  • library is missing from the directory (obviously),
  • library that is dynamically linked with your library is missing,
  • system library versions on the device/emulator that your library uses differ with those that you were linking against in compile time (missing symbols, etc.)

I have described a method that worked for me when resolving an issue with library that was working fine on emulator and was failing to load on Nexus One, maybe this will help you: http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html

这篇关于无法在Android应用程序运行时加载库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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