5

我正在使用 OCR android。从谷歌搜索获得样本并使用 android tesseract。我将该项目作为库并在另一个项目中引用,但是当我运行该项目时,它在 Logcat 中显示以下内容

 07-17 10:38:47.092: ERROR/AndroidRuntime(426): FATAL EXCEPTION: main
    07-17 10:38:47.092: ERROR/AndroidRuntime(426): java.lang.ExceptionInInitializerError
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at com.imagetotext.ImagetoText.onCreate(ImagetoText.java:21)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.os.Handler.dispatchMessage(Handler.java:99)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.os.Looper.loop(Looper.java:123)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at java.lang.reflect.Method.invokeNative(Native Method)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at java.lang.reflect.Method.invoke(Method.java:521)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at dalvik.system.NativeStart.main(Native Method)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426): Caused by: java.lang.UnsatisfiedLinkError: Library liblept not found
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at java.lang.Runtime.loadLibrary(Runtime.java:461)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at java.lang.System.loadLibrary(System.java:557)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47)
    07-17 10:38:47.092: ERROR/AndroidRuntime(426):     ... 14 more
    07-17 10:38:47.112: WARN/ActivityManager(60):   Force finishing activity com.imagetotext/.ImagetoText

我认为我的 android.mk 有问题。请帮我修复错误。

4

1 回答 1

5

异常原因行是,

System.loadLibrary(“lept”);

问题是在特定库路径上找不到liblept.so(共享库)文件。在没有看到您的代码的情况下,仅假设您的代码尝试加载共享库liblept.so并且该库在该路径上不可用。

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.

于 2012-07-17T05:30:34.503 回答