ridoy
ridoy

Reputation: 6322

Configuring Tesseract in Android

I am facing a very weird problem while configuring Tesseract in Android. Following all required steps described here and SO like this and this i have imported tess-two library in eclipse. NDK-build and ant release was also successfull. I have used latest ndk version and android sdk v19(4.4.2).

Next, i had imported a sample project in eclipse written in above blog. All were build successfully. But, when i run the project in a real device, it gives me such a weird error in onPhotoTaken event that possible google search can't answer me nothing!

Logcat says:

08-22 15:04:44.812: V/SimpleAndroidOCR.java(16578): Before baseApi
08-22 15:04:44.812: D/dalvikvm(16578): Trying to load lib /data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so 0x41e56b50
08-22 15:04:44.822: D/dalvikvm(16578): GC_CONCURRENT freed 1K, 14% free 4989K/5788K, paused 2ms+2ms, total 18ms
08-22 15:04:44.822: E/dalvikvm(16578): dlopen("/data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: W/dalvikvm(16578): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/googlecode/tesseract/android/TessBaseAPI;
08-22 15:04:44.832: D/AndroidRuntime(16578): Shutting down VM
08-22 15:04:44.832: W/dalvikvm(16578): threadid=1: thread exiting with uncaught exception (group=0x41be0930)
08-22 15:04:44.832: E/AndroidRuntime(16578): FATAL EXCEPTION: main
08-22 15:04:44.832: E/AndroidRuntime(16578): java.lang.ExceptionInInitializerError
08-22 15:04:44.832: E/AndroidRuntime(16578):    at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.Activity.dispatchActivityResult(Activity.java:5302)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2729)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.os.Looper.loop(Looper.java:137)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at android.app.ActivityThread.main(ActivityThread.java:5041)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at java.lang.reflect.Method.invokeNative(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at dalvik.system.NativeStart.main(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: E/AndroidRuntime(16578):    at java.lang.Runtime.loadLibrary(Runtime.java:371)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at java.lang.System.loadLibrary(System.java:535)
08-22 15:04:44.832: E/AndroidRuntime(16578):    at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
08-22 15:04:44.832: E/AndroidRuntime(16578):    ... 17 more

Probably the most important part of this error message is:

08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...

I checked liblept.so is inside the libs folder of library project that i referenced in my sample project.

Can anyone point me the solution or suggestion of this time-killing problem? Thanks in advance.

Upvotes: 2

Views: 702

Answers (1)

rmtheis
rmtheis

Reputation: 5806

There seems to be a problem with the NDK toolchain version 4.9.

Try pulling the latest version of the tess-two library code, which includes the following in its Application.mk:

NDK_TOOLCHAIN_VERSION := 4.8

You will need to use the "ndk32" version of the NDK for 32-bit targets.

Upvotes: 1

Related Questions