Search code examples
androidandroid-studiotesseractleptonica

Missing allheaders.h in Android Studio Project


I am following the tutorial from this tesseract tutorial and had everything go smoothly up until my actual running of the Java code. When I try

new TessBaseApi();

It throws the following error

Error Code: 2
Output:
In file included from tesstwo/src/main/jni/com_googlecode_leptonica_android/box.cpp:17:0:
tesstwo/src/main/jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
 #include <allheaders.h>
           ^
compilation terminated.
make: *** 

I have looked into /jni/com_googlecode_leptonica_android/src/src and find the allheaders.h file there. I have a feeling my paths are wrong, but I've tried almost everything and no avail. What's the issue?


Solution

  • I also ran into this problem with Android Studio. After googling some more i found this issue. https://code.google.com/p/android/issues/detail?id=74132

    Apparently the NDK plugin generates it's own Android.mk file and ignore any existing one, so the recommended way is to run ndk-build to generate the native .so files.

    When I used ndk-build in the tess-two directory it compiles just fine and the .so files is created.

    How you can include native libraries in gradle and android studio is described in this post: Add pre-built .so files in project using Android Gradle plugin 0.7.3