我已下载tess-two,然后将所有文件从该位置导入到我的项目中。编译* .so文件,然后尝试像这样在我的手机上运行该文件:

    TessBaseAPI baseApi = new TessBaseAPI();
    baseApi.setDebug(true);
    baseApi.init(DATA_PATH, lang);
    baseApi.setImage(bitmap);
    String recognizedText = baseApi.getUTF8Text();
    baseApi.end();


但是结果很可悲:

02-06 15:43:32.095    4072-4072/my.package.name E/AndroidRuntime? FATAL EXCEPTION: main
Process: my.package.name, PID: 4072
java.lang.UnsatisfiedLinkError: Native method not found: my.package.name.tesseract.android.TessBaseAPI.nativeClassInit:()V
        at my.package.name.tesseract.android.TessBaseAPI.nativeClassInit(Native Method)
        at my.package.name.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:46)
        at my.package.name.activities.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:214)
        at my.package.name.activities.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:138)
        at android.app.Activity.dispatchActivityResult(Activity.java:5441)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3353)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3400)
        at android.app.ActivityThread.access$1300(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1250)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5047)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
        at dalvik.system.NativeStart.main(Native Method)


谁能帮我解决这个问题?

最佳答案

您好,我认为您没有编译与所有CPU匹配的* .so文件。

请按如下方式编辑Application.mk


APP_STL:= gnustl_static
APP_ABI:= armeabi armeabi-v7a x86 mips arm64-v8a x86_64 mips64
APP_OPTIM:=发布
APP_PLATFORM:= android-9
APP_CPPFLAGS + = -fexceptions -frtti
NDK_TOOLCHAIN_VERSION:= lang

然后编译最好的问候

08-05 00:06