Android Tesseract App crashes on OCR Function

I am trying to implement Tesseract into my android project but am getting a crash when trying to complete the OCR.

Here is how I'm setting up Tesseract:

 TessBaseAPI baseApi = new TessBaseAPI();
        baseApi.init(imagePath, "eng");
        String recognizedText = baseApi.getUTF8Text();

This is how I'm setting up the image information to pass into the TesseractAPI:

        destination = new File(Environment.getExternalStorageDirectory(), name + ".png");

        imagePath = destination.getAbsolutePath();

        String name =   dateToString(new Date(),"yyyy-MM-dd-hh-mm-ss");

Here is the Logcat:

10734-10734/ E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process:, PID: 10734
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find ""
            at java.lang.Runtime.loadLibrary(
            at java.lang.System.loadLibrary(
            at android.os.Handler.dispatchMessage(
            at android.os.Looper.loop(
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(


Your tesseract does not crash in the OCR function, it crashes trying to load a library:

java.lang.UnsatisfiedLinkError: ... couldn't find ""

But line 43 in the source that I have reads:


therefore it tries to load but reports a failure on


1) your source code of is different, it contains System.loadLibrary("pngt"); and that library is missing. Make sure the .apk contains it. Eclipse used to have a misfeature: if your code depends on a library, you configure that dependency for compilation in one place and for delivery in another place. And IIRC .so dependency was specified in a 3rd place.

2) is compiled with dynamic linking (try to use static linking then)

3) you are trying to run it in the emulator (try on a real device then).

This is all what can be said from the information you provided.

More info about solution:

I faced with this issue when I moved from Windows to Linux. My Linux had no NDK installed.

I've downloaded it from official source.

Instructions for installing under Linux:

Go to the directory where you downloaded it. Execute the package. For example:

ndk$ chmod a+x android-ndk-r10c-darwin-x86_64.bin
ndk$ ./android-ndk-r10c-darwin-x86_64.bin

You also need to rebuild tess-two under Linux. Follow the instruction in oficial source.

Make sure that you are using the same gradle version on your project and in the tess lib project. Example:

buildscript {
    dependencies {
        classpath ''

The value on classpath must be equals on both projects.

  1. do not update any gradle aur sdk update... i repeat ignore all the update if asking and it will work smoothly. Just import the project of priyankverma######## from github and IGNORE all the updates ... i am sure you wont get this error.
    1. Download or clone the project
    2. import in android studio
    3. let the gradle and sdk versions as it is and
    4. IGNORE all the UPDATES even it is saying "Strongly Recommended.
    5. simply run the project. :)

Need Your Help

Grails 3.0 / IntelliJ 14.1.4 creating controllers, services, domain classes not working

grails intellij-idea gradle

When I try to create a Grails domain class, controller (anything, really) using IntelliJ 14.1.4 results in failures from the Gradle commands that IntelliJ is calling, for instance: