Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 811
Michael Avatar asked Oct 19 '22 19:10

Michael


2 Answers

This works for me: https://coderwall.com/p/eurvaq/tesseract-with-andoird-and-gradle

But do not delete libs directory!

Set compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersio to the same values as in project buil.gradle

I also change classpath 'com.android.tools.build:gradle:0.9.+' to classpath 'com.android.tools.build:gradle:1.0.+'

like image 29
Macek_82 Avatar answered Oct 22 '22 08:10

Macek_82


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

like image 67
Anders Asplund Avatar answered Oct 22 '22 10:10

Anders Asplund