Open FarisSpahic opened 3 months ago
Are you attempting to run the plugin within an Android application?
Yes, I want to use already generated libflusseract.so file within flutter generated android app. I like this plugin because it offers bytestream tesseract processing, unlike the others where you must create an InputImage object and work with I/O. However, this plugin takes some time to generate libflusseract.so file and that's too slow for me.
To get the android FFI code + shared libs of the plugin to build and be packaged correctly you will need to make some changes to you apps build.gradle - for example see the one here: https://github.com/letterassist-ai/flusseract/blob/main/example/android/app/build.gradle. Also can you see if you can build and run the example app in the android emulator. I have tested this on a Pixel_3a_API_34_extension_level_7_arm64-v8a
emulator.
Ok, may be I am mis-understanding you original question. I see you were able to build the *.so. I assume are trying to avoid re-building which will happen anytime you clean you flutter project as this will remove all plugin native builds. Unfortunately copying to your apps assets and loading it manually will not work. Let me know if this is the issue.
I will try to be more concrete. I have your libflusseract.so file that is a Dlib connected to flutter bindings. Next, I just want to use your code without adding entire plugin because if I do that, I will need to generate libflusseract.so file on init() method, which is slow for me. So, I am using your code from lib folder of plugin. When I try to call DynamicLibrary.open('libflusseract.so') it breaks because it's not loaded into the apk root lib folder. How can I load this .so file in my project so that I'm able to use it. I'm not trying to load it from assets folder.
Modify the android/apps/build.gradle
of your project to do an external build - i.e. https://github.com/android/ndk-samples/blob/main/hello-libs/app/build.gradle. Then create a CMakeLists.txt file at the location that copies the libflusseract.so - i.e. https://stackoverflow.com/questions/71213677/how-do-i-add-so-file-to-lib-folder-in-apk. This should add the .so to the APK's lib folder.
Hello :) I am trying to use flusseract with my app that uses camera and needs constant camera frame processing, but this error constantly pops up:
Invalid argument(s): Failed to load dynamic library 'libflusseract.so': dlopen failed: library "libflusseract.so" not found
I am trying to use already compiled files to skip flusseract module generation. I found the .so file and put it in the assets folder. When I explicitly try to access it from assets folder, it fails again. Tried accessing the file directly from these app directories and still didn't work.
I/flutter (31413): /data/user/0/com.app.host/app_flutter/tessdata I/flutter (31413): /data/user/0/com.app.host/app_flutter/flutter_assets I/flutter (31413): /data/user/0/com.app.host/app_flutter/res_timestamp-1-1713186218368
Is there a way to use the libflusseract.so file so it doesn't need to compile in real time?