机器人的UnsatisfiedLinkError:库未找到机器人、未找到、UnsatisfiedLinkError

由网友(不远不近的洒脱∫)分享简介:我检查了coolreader 3从Git仓库 http://sourceforge.net/projects/crengine/。我试着在Eclipse中构建它,但在运行时,出现以下错误崩溃:I checked out coolreader 3 from git repository http://sourcefo...

我检查了coolreader 3从Git仓库 http://sourceforge.net/projects/crengine/。 我试着在Eclipse中构建它,但在运行时,出现以下错误崩溃:

I checked out coolreader 3 from git repository http://sourceforge.net/projects/crengine/. I try to build it in eclipse, but when running it crashes with the following error:

应用程序酷阅读器(process.org.coolreader)意外停止。请重试。

The application Cool Reader (process.org.coolreader) has stopped unexpectedly. Please try again.

下面是红色部分来自logcat的:

Here is the red part from logcat:


08-27 02:54:24.553: ERROR/AndroidRuntime(223): Uncaught handler: thread BackgroundThread44c32540 exiting due to uncaught exception
08-27 02:54:24.583: ERROR/AndroidRuntime(223): java.lang.UnsatisfiedLinkError: Library cr3engine-45-15 not found
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at java.lang.Runtime.loadLibrary(Runtime.java:489)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at java.lang.System.loadLibrary(System.java:557)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at org.coolreader.crengine.Engine.installLibrary(Engine.java:837)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at org.coolreader.crengine.Engine.init(Engine.java:745)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at org.coolreader.crengine.Engine.access$10(Engine.java:742)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at org.coolreader.crengine.Engine$4.run(Engine.java:565)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at android.os.Handler.handleCallback(Handler.java:587)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at android.os.Looper.loop(Looper.java:123)
08-27 02:54:24.583: ERROR/AndroidRuntime(223):     at org.coolreader.crengine.BackgroundThread.run(BackgroundThread.java:120)

和这是函数org.coolreader.crengine.Engine.installLibrary:

and this is the function org.coolreader.crengine.Engine.installLibrary:

private void installLibrary() {
    try {
        if (force_install_library)
            throw new Exception("forcing install");
        // try loading library w/o manual installation
        log.i("trying to load library " + LIBRARY_NAME
                + " w/o installation");
        System.loadLibrary(LIBRARY_NAME);
        // try invoke native method
        //log.i("trying execute native method ");
        //setHyphenationMethod(HYPH_NONE, new byte[] {});
        log.i(LIBRARY_NAME + " loaded successfully");
    } catch (Exception ee) {
        log.i(SO_NAME + " not found using standard paths, will install manually");
        File sopath = mActivity.getDir("libs", Context.MODE_PRIVATE);
        File soname = new File(sopath, SO_NAME);
        try {
            sopath.mkdirs();
            File zip = new File(mActivity.getPackageCodePath());
            ZipFile zipfile = new ZipFile(zip);
            ZipEntry zipentry = zipfile.getEntry("lib/armeabi/" + SO_NAME);
            if (!soname.exists() || zipentry.getSize() != soname.length()) {
                InputStream is = zipfile.getInputStream(zipentry);
                OutputStream os = new FileOutputStream(soname);
                Log.i("cr3",
                        "Installing JNI library "
                                + soname.getAbsolutePath());
                final int BUF_SIZE = 0x10000;
                byte[] buf = new byte[BUF_SIZE];
                int n;
                while ((n = is.read(buf)) > 0)
                    os.write(buf, 0, n);
                is.close();
                os.close();
            } else {
                log.i("JNI library " + soname.getAbsolutePath()
                        + " is up to date");
            }
            System.load(soname.getAbsolutePath());
            //setHyphenationMethod(HYPH_NONE, new byte[] {});
        } catch (Exception e) {
            log.e("cannot install " + LIBRARY_NAME + " library", e);
        }
    }
}

在engine.java行837:

The line 837 in engine.java:

 System.loadLibrary(LIBRARY_NAME);

LIBRARY_NAME在engine.java被设置:

LIBRARY_NAME in engine.java is set by:

 static final private String LIBRARY_NAME = "cr3engine-45-15";

由于我从库中下载了code,假定没有任何修改工作。我不明白为什么它不工作。

Since I downloaded the code from repository it is supposed to work without any modifications. I don't understand why it's not working.

推荐答案

这些都是不规范的名字,因为他们缺乏的lib preFIX。

Those are not standard names, as they lack the lib prefix.

System.loadLibrary("lept");
System.loadLibrary("tess");

这是导致搜索liblept.so这是不是你的文件。要么给你的库中的标准名称,或指定一个实际的文件名,包括在那里结束了安装在设备上的路径

This is causes search for liblept.so which is not the file you have. Either give your library the standard name, or specify an actual file name including the path where it ends up installed on the device to

System.load(("lept") 
//rather than 
System.loadLibrary().

如果它的 unsatisfiedlink错误,然后在没有看到你的code仅仅只假设你的code试图加载共享库的 liblept.so 和库不可用这条道路。另外,code使用的是要么有,在任何lib或内部包目录liblept.so文件,或者你必须生成(编译),通过使用共享库的Andr​​oid NDK 尝试以下< STRONG> 教程1 ,的 tutorial2

if it's unsatisfiedlink error then Without seeing your code just only assumption is your code trying to load shared library liblept.so and the library is not available at that path. Also the code you are using is either have that liblept.so file in any lib or internal package directory or you have to generate (build) that shared library by using Android-NDK try following tutorial1 , tutorial2

阅读全文

相关推荐

最新文章