0

When I am running the code below on a real device (ZTE, Android 4.2.2) I got an error:

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

Error in 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)

I am packaging a project into AutoRunner.jar and push the jar to a real device. The problem seems to be that the liblept.so and libtess.so file cannot be loaded from the device.

  • yes, i got BUILD SUCCESSFUL, the error occurs when i am running adb shell uiautomator runtest AutoRunner.jar -c com.***.**** –  Oct 14 '15 at 03:09
  • Can you explain what you're trying to do? Are you trying to run an automation script on an existing app? Does the app work properly when run standalone? – rmtheis Oct 14 '15 at 03:29
  • I am running a java class which extends uiautomatortestcase class. The app works properly without the TessBaseApi code above. –  Oct 14 '15 at 05:07

1 Answers1

0

I find a solution here: open cmd then execute: adb push ...\liblept.so system/lib and adb push ...\libtess.so system/lib (the file path is under tess-two folder)

change the code:

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

to:

System.load("/system/lib/liblept.so");
System.load("/system/lib/libtess.so");