title: App crashing when running bytedeco tesseract in Flutter with Java MethodChannel
body: <p>I'm trying to use the <a href="https://github.com/bytedeco/javacpp-presets/tree/master/tesseract" rel="nofollow noreferrer">bytedeco tesseract</a> java wrapper inside Flutter using MethodChannel, however I'm getting error. I've tried flutter clean and upgraded gradle to 4.2.2 yet still didn't work. My suspicion is towards installing the dependencies properly</p>
  <p>The dependencies I added via Maven are as below:</p>
  <p>android/app/build.gradle</p>
  <pre><code>dependencies {
      implementation 'org.bytedeco:javacpp:1.5.6'
      implementation 'org.bytedeco:javacpp-presets:1.5.6'
  
      implementation 'org.bytedeco:leptonica:1.81.1-1.5.6'
  
      implementation 'org.bytedeco:tesseract:4.1.1-1.5.6'
  }
  </code></pre>
  <p>android/app/src/main/java/com/example/ocr_app_test_v2/MainActivity.java</p>
  <pre><code>package com.example.ocr_app_test_v2;
  
  import io.flutter.embedding.android.FlutterActivity;
  import androidx.annotation.NonNull;
  
  
  import io.flutter.embedding.engine.FlutterEngine;
  import io.flutter.plugin.common.MethodChannel;
  
  import org.bytedeco.javacpp.*;
  import org.bytedeco.leptonica.*;
  import org.bytedeco.tesseract.*;
  import static org.bytedeco.leptonica.global.lept.*;
  import static org.bytedeco.tesseract.global.tesseract.*;
  
  public class MainActivity extends FlutterActivity {
  
      private static final String CHANNEL = &quot;samples.flutter.dev/ocr&quot;;
  
      @Override
      public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
          super.configureFlutterEngine(flutterEngine);
          new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
                  .setMethodCallHandler(
                          (call, result) -&gt; {
                              // Note: this method is invoked on the main thread.
                              // Note: this method is invoked on the main thread.
                              if (call.method.equals(&quot;getOCR_result&quot;)) {
                                  String batteryLevel = getOCR_result();
  
                                  result.success(batteryLevel);
                              } else {
                                  result.notImplemented();
                              }
                          }
                  );
      }
  
  
  
  
  
      public String getOCR_result() {
          BytePointer outText;
  
          TessBaseAPI api = new TessBaseAPI();
          // Initialize tesseract-ocr with English, without specifying tessdata path
          if (api.Init(null, &quot;eng&quot;) != 0) {
              System.err.println(&quot;Could not initialize tesseract.&quot;);
              System.exit(1);
          }
  
          // Open input image with leptonica library
          PIX image = pixRead(&quot;/Users/nameHere/AndroidStudioProjects/ocr_app_test_v2/src_ocr/test_pic.png&quot;);
          api.SetImage(image);
          // Get OCR result
          outText = api.GetUTF8Text();
          System.out.println(&quot;OCR output:\n&quot; + outText.getString());
  
          // Destroy used object and release memory
          //api.End();
          ///outText.deallocate();
          //pixDestroy(image);
  
  
          return outText.getString();
      }
  }
  </code></pre>
  <p>The dart method I implemented:</p>
  <pre><code>import 'dart:async';
  
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  
  Future&lt;String&gt; getOCR_result_dart() async {
    const platform = MethodChannel('samples.flutter.dev/ocr');
  
    try {
      final String result = await platform.invokeMethod('getOCR_result');
      print('resutls are here: ' + result);
      return result;
    } on PlatformException catch (e) {
      return &quot;ocr error&quot;;
    }
  }
  </code></pre>
  <p>Error I get:</p>
  <pre><code>W/System.err( 1283): Warning: Version of org.bytedeco:leptonica could not be found.
  E/AndroidRuntime( 1283): FATAL EXCEPTION: main
  E/AndroidRuntime( 1283): Process: com.example.ocr_app_test_v2, PID: 1283
  E/AndroidRuntime( 1283): java.lang.UnsatisfiedLinkError: dlopen failed: library &quot;libjnilept.so&quot; not found
  E/AndroidRuntime( 1283):    at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
  E/AndroidRuntime( 1283):    at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
  E/AndroidRuntime( 1283):    at java.lang.System.loadLibrary(System.java:1664)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1738)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1345)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1157)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1133)
  E/AndroidRuntime( 1283):    at org.bytedeco.leptonica.global.lept.&lt;clinit&gt;(lept.java:14)
  E/AndroidRuntime( 1283):    at java.lang.Class.classForName(Native Method)
  E/AndroidRuntime( 1283):    at java.lang.Class.forName(Class.java:454)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1212)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1157)
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.load(Loader.java:1133)
  E/AndroidRuntime( 1283):    at org.bytedeco.tesseract.TessBaseAPI.&lt;clinit&gt;(TessBaseAPI.java:26)
  E/AndroidRuntime( 1283):    at com.example.ocr_app_test_v2.MainActivity.getOCR_result(MainActivity.java:52)
  E/AndroidRuntime( 1283):    at com.example.ocr_app_test_v2.MainActivity.lambda$configureFlutterEngine$0$MainActivity(MainActivity.java:35)
  E/AndroidRuntime( 1283):    at com.example.ocr_app_test_v2.-$$Lambda$MainActivity$j1X8cjOgJ0mnzzaqcNKQtS4D12U.onMethodCall(Unknown Source:2)
  E/AndroidRuntime( 1283):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
  E/AndroidRuntime( 1283):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
  E/AndroidRuntime( 1283):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
  E/AndroidRuntime( 1283):    at android.os.MessageQueue.nativePollOnce(Native Method)
  E/AndroidRuntime( 1283):    at android.os.MessageQueue.next(MessageQueue.java:335)
  E/AndroidRuntime( 1283):    at android.os.Looper.loop(Looper.java:206)
  E/AndroidRuntime( 1283):    at android.app.ActivityThread.main(ActivityThread.java:8595)
  E/AndroidRuntime( 1283):    at java.lang.reflect.Method.invoke(Native Method)
  E/AndroidRuntime( 1283):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
  E/AndroidRuntime( 1283):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
  E/AndroidRuntime( 1283): Caused by: java.lang.UnsatisfiedLinkError: Could not find jnilept in class, module, and library paths.
  E/AndroidRuntime( 1283):    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1705)
  E/AndroidRuntime( 1283):    ... 23 more
  I/Process ( 1283): Sending signal. PID: 1283 SIG: 9
  Lost connection to device.
  </code></pre>