无法在 Android 应用程序运行时加载库

发布于 2024-09-01 12:48:28 字数 1102 浏览 1 评论 0原文

我正在开发 android 应用程序,其中我使用 JNI 作为本机 c 代码。 我在 android 2.0 版本和 ndkr3 上构建这个应用程序,它运行良好。

现在,当我更改android sdk版本1.5和api版本3时,我遇到了无法打开库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

我将 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): 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你再特殊 2024-09-08 12:48:28

此错误几乎总是显示“找不到库”,造成这种情况的原因可能有很多。令人烦恼的是,在大多数情况下,不是缺少库而是其他东西。我偶然发现的原因:

  • 目录中缺少库(显然)、
  • 与您的库动态链接的库丢失、
  • 您的库使用的设备/模拟器上的系统库版本与您在编译时链接的版本不同(缺少符号等)

我描述了一种在解决库问题时对我有用的方法,该库在模拟器上运行良好但无法在 Nexus One 上加载,也许这会对您有所帮助:http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文