Android-java.lang.IllegalStateException:无法执行活动的方法

时间:2014-08-12 10:43:41

标签: android ocr

我正在制作一个图片到文字的Android应用,我正在尝试使用tess-two库从图库图像中获取文字。我正在使用github代码,例如此链接“https://github.com/TheWall89/AndrOCR”。

我查看了AndrOCR ShowImage.java中的一些错误。

这是我的Logcat结果:

08-12 10:25:02.269: E/AndroidRuntime(22697): FATAL EXCEPTION: main
08-12 10:25:02.269: E/AndroidRuntime(22697): java.lang.IllegalStateException: Could not execute method of the activity
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.view.View$1.onClick(View.java:3591)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.view.View.performClick(View.java:4084)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.view.View$PerformClick.run(View.java:16966)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.os.Handler.handleCallback(Handler.java:615)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.os.Looper.loop(Looper.java:137)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.app.ActivityThread.main(ActivityThread.java:4745)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.reflect.Method.invokeNative(Native Method)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.reflect.Method.invoke(Method.java:511)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at dalvik.system.NativeStart.main(Native Method)
08-12 10:25:02.269: E/AndroidRuntime(22697): Caused by: java.lang.reflect.InvocationTargetException
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.reflect.Method.invokeNative(Native Method)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.reflect.Method.invoke(Method.java:511)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.view.View$1.onClick(View.java:3586)
08-12 10:25:02.269: E/AndroidRuntime(22697):    ... 11 more
08-12 10:25:02.269: E/AndroidRuntime(22697): Caused by: java.lang.ExceptionInInitializerError
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.matpergo.androcr.ShowImage.initTess(ShowImage.java:241)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.matpergo.androcr.ShowImage$OCR.onPreExecute(ShowImage.java:654)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at android.os.AsyncTask.execute(AsyncTask.java:534)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.matpergo.androcr.ShowImage.startOCR(ShowImage.java:259)
08-12 10:25:02.269: E/AndroidRuntime(22697):    ... 14 more
08-12 10:25:02.269: E/AndroidRuntime(22697): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lept: findLibrary returned null
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.Runtime.loadLibrary(Runtime.java:365)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at java.lang.System.loadLibrary(System.java:535)
08-12 10:25:02.269: E/AndroidRuntime(22697):    at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
08-12 10:25:02.269: E/AndroidRuntime(22697):    ... 19 more
08-12 10:25:04.033: I/Process(22697): Sending signal. PID: 22697 SIG: 9

我认为错误应该在showImage类的下面代码中。

//库初始化

public void initTess() {
    if (mBaseApi != null)
        mBaseApi.end();

    mBaseApi = new TessBaseAPI();
    mBaseApi.setDebug(false);
    mBaseApi.setPageSegMode(mSegMode);
    mBaseApi.init(mDataDir + File.separator, mLang,
            TessBaseAPI.OEM_TESSERACT_ONLY);
    // Log.w(TAG, "initTess executed: " + mSegMode + "," + mLang);
} 

1 个答案:

答案 0 :(得分:1)

从日志中看起来系统无法找到.so本机库。检查您是否正确复制了那些