Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "png_set_longjmp_fn" referenced by "liblept.so"... #106

Closed
Linkaan opened this issue Aug 10, 2015 · 12 comments

Comments

@Linkaan
Copy link

Linkaan commented Aug 10, 2015

When trying to load the lept library, my app crashes because apparently it can't locate symbol "png_set_longjmp_fn". I tried rebuilding the libpng shared library by the name libpng-1.6.2 and changing to System.loadLibrary("png-1.6.2");in TestBaseAPI.java but it still crashes my app. I am using this example and I've compiled tess-two with the latest ndk 32 bit version.

Here is the full stacktrace:

08-10 15:49:07.450  30307-30307/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.myapp PID: 30307
    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "png_set_longjmp_fn" referenced by "liblept.so"...
            at java.lang.Runtime.loadLibrary(Runtime.java:364)
            at java.lang.System.loadLibrary(System.java:526)
            at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
            at com.example.myapp.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211)
            at com.example.myapp.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135)
            at android.app.Activity.dispatchActivityResult(Activity.java:5423)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3385)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)
            at android.app.ActivityThread.access$1300(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:732)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
            at dalvik.system.NativeStart.main(Native Method)

Here is my build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

apply plugin: 'android-library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

    sourceSets.main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        res.srcDirs = ['res']
        jniLibs.srcDirs = ['libs']
    }
}

I'm running this on my Samsung Galaxy S4 ks01lte running Cyanogen-mod.

@rmtheis
Copy link
Owner

rmtheis commented Aug 10, 2015

Do you get the same error when you run the unit tests?

@rmtheis
Copy link
Owner

rmtheis commented Aug 10, 2015

And do you also get the same error when you run on a non-Cyanogen-mod device, or an emulator?

@Linkaan
Copy link
Author

Linkaan commented Aug 10, 2015

@rmtheis I will try. How would I run the unit tests? I am using windows as my development machine.

@smac89
Copy link

smac89 commented Aug 14, 2015

@Linkaan if you are using android studio, you should post your build.gradle file for tess-two

@Linkaan
Copy link
Author

Linkaan commented Aug 14, 2015

@smac89 Thanks for the tip, I just added it.

@festplatte
Copy link

I got the same error while trying to get a new instance of TessBaseAPI and I think that it's a bug in the master version of tess-two. Now I downloaded version 5.1.0 and everything works just fine. Maybe this can solve your problem, too.

@smac89
Copy link

smac89 commented Aug 21, 2015

@Linkaan
If you still didn't get it to work for you, try this build.gradle file:

apply plugin: 'com.android.library'

android {

    compileSdkVersion 23
    buildToolsVersion "23.0.0"


    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22

        ndk {
            moduleName "tess-two"
        }
    }


    sourceSets.main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        res.srcDirs = ['res']
        jniLibs.srcDir 'libs'
        jni.srcDirs = []
        aidl.srcDirs = ['src']
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-project.txt')
        }
    }
}

Also make sure your proguard.pro file contains the following:

# tess-two
-keep class com.googlecode.leptonica.android.Box {
    private long mNativeBox;
}
-keep class com.googlecode.leptonica.android.Boxa {
    private long mNativeBoxa;
}
-keep class com.googlecode.leptonica.android.Pix {
    private long mNativePix;
}
-keep class com.googlecode.leptonica.android.Pixa {
    private long mNativePixa;
}
-keep class com.googlecode.tesseract.android.TessBaseAPI {
    private long mNativeData;
    protected void onProgressValues(int, int, int, int, int, int, int, int, int);
}
-keep class com.googlecode.tesseract.android.PageIterator {
    private long mNativePageIterator;
}
-keep class com.googlecode.tesseract.android.TessPdfRenderer {
    private long mNativePdfRenderer;
}
-keep class com.googlecode.tesseract.android.ResultIterator {
    private long mNativeResultIterator;
}

@mhd-adeeb-masoud
Copy link

In my case it's only happening on my note II. All my other devices are working fine.
@Linkaan I tried your solution also did not work.
I will try to pull 5.1 and try again :)

@makelove
Copy link

downloaded version 5.2.0 ,every problems is gone.
my Environment is
Mac OSX 10.10
latest Android Studio 1.3
SDK r22,NDK r10e

@rmtheis
Copy link
Owner

rmtheis commented Aug 24, 2015

@Linkaan Thanks for the report. This is fixed in the latest commit.

@julianoabrs
Copy link

I'm sorry, but version 5.2.0 of what component?!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants