0

当我在真实设备(ZTE,Android 4.2.2)上运行以下代码时,出现错误:

    _tessApi = new TessBaseAPI();
    _tessApi.setDebug(false);
    try {
        _tessApi.init(Environment.getExternalStorageDirectory().getPath(), "chi_sim");
        _useOcr = true;
    } catch (Exception ex) {
        _useOcr = false;
    }

testRunner 中的错误:

java.lang.UnsatisfiedLinkError: Couldn't load lept from loader dalvik.system.PathClassLoader[DexPathList[[
zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/uiautomator.jar", zip fi
le "/data/local/tmp/AutoRunner.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary re
turned null
        at java.lang.Runtime.loadLibrary(Runtime.java:366)
        at java.lang.System.loadLibrary(System.java:514)
        at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
        at com.base.jqhelper.initOCR(jqhelper.java:38)
        at com.tieba.AddFriend.Initialization(AddFriend.java:328)
        at com.tieba.AddFriend.testRunner(AddFriend.java:43)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:144)
        at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:87)
        at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:90)
        at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
        at dalvik.system.NativeStart.main(Native Method)

我正在将一个项目打包到 AutoRunner.jar 中并将 jar 推送到真实设备。问题似乎是无法从设备加载 liblept.so 和 libtess.so 文件。

4

1 回答 1

0

我在这里找到了解决方案:打开cmd然后执行:adb push ...\liblept.so system/libadb push ...\libtess.so system/lib(文件路径在tess-two文件夹下)

更改代码:

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

至:

System.load("/system/lib/liblept.so");
System.load("/system/lib/libtess.so");
于 2015-10-15T09:22:33.773 回答