无法在 Android 应用程序运行时加载库
我正在开发 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误几乎总是显示“找不到库”,造成这种情况的原因可能有很多。令人烦恼的是,在大多数情况下,不是缺少库而是其他东西。我偶然发现的原因:
我描述了一种在解决库问题时对我有用的方法,该库在模拟器上运行良好但无法在 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:
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