gustavomazzoni / cordova-plugin-tesseract

Cordova Plugin for OCR process using Tesseract
77 stars 34 forks source link

Runtime error : ... couldn't find "libjpgt.so" #27

Open GuillaumeNachury opened 7 years ago

GuillaumeNachury commented 7 years ago

Hello, I'm trying to use the plugin on an Android (6.0.1) but when I call the recognizeText method I got this error :

06-29 22:08:45.412 31275 31408 W System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.ionic.starter-1/base.apk"],nativeLibraryDirectories=[/data/app/io.ionic.starter-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjpgt.so"
06-29 22:08:45.419 31275 31408 W System.err:    at java.lang.Runtime.loadLibrary(Runtime.java:367)
06-29 22:08:45.419 31275 31408 W System.err:    at java.lang.System.loadLibrary(System.java:1076)
06-29 22:08:45.419 31275 31408 W System.err:    at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
06-29 22:08:45.419 31275 31408 W System.err:    at com.gmazzoni.cordova.TesseractPlugin.recognizeText(TesseractPlugin.java:80)
06-29 22:08:45.419 31275 31408 W System.err:    at com.gmazzoni.cordova.TesseractPlugin.execute(TesseractPlugin.java:48)
06-29 22:08:45.419 31275 31408 W System.err:    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
06-29 22:08:45.419 31275 31408 W System.err:    at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
06-29 22:08:45.419 31275 31408 W System.err:    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
06-29 22:08:45.419 31275 31408 W System.err:    at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
06-29 22:08:45.419 31275 31408 W System.err:    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
06-29 22:08:45.419 31275 31408 W System.err:    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)
06-29 22:08:45.419 31275 31408 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
06-29 22:08:45.420 31275 31408 W System.err:    at android.os.Looper.loop(Looper.java:148)
06-29 22:08:45.420 31275 31408 W System.err:    at android.os.HandlerThread.run(HandlerThread.java:61)

Any idea how embed this libjpgt lib ?

Thank you

palucdev commented 7 years ago

Hey! Recently I had the same problem and managed to resolve it by changing dependency name in platforms/android/build.gradle from compile project(':tess-two') to compile 'com.rmtheis:tess-two:7.0.0' (right after // SUB-PROJECT DEPENDENCIES END comment). If in any case you dont want to change dependency, there is another fix: adding

static{
    System.loadLibrary("jpgt");
    System.loadLibrary("pngt");
    System.loadLibrary("lept");
    System.loadLibrary("tess");
  }

to TesseractPlugin.java file.