无法执行dlopen(libsomething.so)无法加载库:link_image [1995]:无法连接libsomething.so加载、libsomething、dlopen、so

由网友(静孤芳自赏)分享简介:我写一个Android项目,有原生层帮助了Java层,和我停留在一个地方,当我尝试做的System.loadLibrary,它抛出的错误,这是不能够联系起来。 I am writing an android project which has Native layer helping the java layer,...

我写一个Android项目,有原生层帮助了Java层,和我停留在一个地方,当我尝试做的System.loadLibrary,它抛出的错误,这是不能够联系起来。

I am writing an android project which has Native layer helping the java layer, and am stuck at a place where when i try to do a System.loadLibrary, it is throwing error that it is not able to link it.

我使用的目标具体NDK构建本地图层,然后使用Ant编译和创建APK。

I am using Target specific NDK to build the native layer, and then using ant to compile and create the apk.

在设备上我碰到下面的错误上运行。

On running on the device i get the following error.

无法执行dlopen(libsomething.so)无法加载库:link_image [1995]:无法连接libsomething.so

Unable to dlopen(libsomething.so) Cannot load library: link_image[1995]: failed to link libsomething.so

该库获得捆绑到apk文件,并正确解压。如果我尝试手动删除库中,然后运行它,然后它居然抛出了找不到库。因此,它是能够找到库,但它抛出这个错误,我不能够找出为什么这个错误是来了。

The library get bundled into the apk, and is unpacked properly. If i try to remove the library manually and then run it, it then actually throws that library not found. So it is able to find the library, but it throws this error, and i am not able to find out why this error is coming.

请帮我。

推荐答案

首先找到.so文件的位置。然后可以试试:

First find the location of the .so file. and then can try:

下面的例子假定共享库的位置: /data/data/my.package/lib/libmysharedlibrary.so

Following example assumes the location of shared library as: /data/data/my.package/lib/libmysharedlibrary.so

try {
    //System.loadLibrary("mysharedlibrary");
    System.load("/data/data/my.package/lib/libmysharedlibrary.so");
} catch (UnsatisfiedLinkError use) {
    Log.e("JNI", "WARNING: Could not load libmysharedlibrary.so");
}
阅读全文

相关推荐

最新文章