allheaders失踪。h在Android Studio项目中。

时间:2022-01-13 23:28:05

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

我正在跟随这个tesseract教程的教程,在我实际运行Java代码之前,一切都很顺利。当我尝试

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?

我已经查看了/jni/com_googlecode_leptonica_android/src/src,并找到了allheaders。h文件。我有一种感觉,我的道路是错的,但我尝试了几乎所有的事情,却没有成功。这个问题是什么?

5 个解决方案

#1


1  

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

我也在安卓工作室遇到了这个问题。在谷歌搜索之后,我发现了这个问题。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.

显然,NDK插件产生了自己的Android。mkfile并忽略任何现有的文件,所以推荐的方法是运行ndk-build生成本机。

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

当我使用ndk-build在tres - 2目录时,它编译的很好,所以文件就被创建了。

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

如何在gradle和android studio中包含本地库,在本文中描述:添加预构建。因此,使用android gradle插件的项目中使用的文件是0.7.3 ?

#2


1  

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

这对我来说很有用:https://coderwall.com/p/eurvaq/tesseract- withandoird -gradle。

But do not delete libs directory!

但是不要删除libs目录!

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

将编译版本、buildToolsVersion、minSdkVersion和targetSdkVersio设置为与项目构建相同的值。

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

我还更改类路径的com.android.tools.build:gradle:0.9。+“路径”com.android.tools.build:gradle:1.0 +”。

#3


1  

At some point Android Studio suggests to set jni.srcDirs = []

在某个时候,Android Studio建议设置jni。srcdir =[]

leading to following sourceSets in the gradle.build of my tess-two library project

导致在gradle中有以下的sourceSets。建立我的国际象棋-两个图书馆项目。

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

With correct src path entered here this actualy works

在这里输入正确的src路径,这是实际工作。

#4


0  

I'm not sure if it works for you but in my case, here's what I've done:

我不确定它是否适用于你,但在我的案例中,这是我所做的:

1. In common.h: change #include <allheaders.h> into #include <src/src/allheaders.h>.

2. In the library project build.gradle: add this

sourceSets{
    main {
        manifest.srcFile 'AndroidManifest.xml'
        jni.srcDirs = []
        jniLibs.srcDirs = ['src/main/jniLibs']
        resources.srcDirs = ['src']
        res.srcDirs = ['res']

    }
}

#5


0  

Ppl, After struggling a day.. finally got the solution

在挣扎了一天之后。终于得到了解决

In build.gradle of tess-two module add the below code:

在构建。tess- 2模块的gradle添加以下代码:

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

Main thing is please check manually weather all those file paths specified in above code exists in tess-two module!!

主要问题是,请手动检查以上代码中指定的所有文件路径是否存在于t_ - 2模块中!!

Check in which path "liblept.so" and other ".so" files exist in tess-two library. For me it was inside /tesstwo/src/main/jniLibs/armeabi-v7a . Hence i have made jniLibs.srcDirs = ['src/main/jniLibs'] in above code. Hope it helps !!

检查路径“liblept”。所以“等”。因此,“文件存在于t_ - 2库中”。对我来说,它是在/tesstwo/src/main/jniLibs/armeabi-v7a。因此我做了jniLibs。在上面的代码中,srcDirs = ['src/main/jniLibs']。希望它帮助! !

#1


1  

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

我也在安卓工作室遇到了这个问题。在谷歌搜索之后,我发现了这个问题。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.

显然,NDK插件产生了自己的Android。mkfile并忽略任何现有的文件,所以推荐的方法是运行ndk-build生成本机。

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

当我使用ndk-build在tres - 2目录时,它编译的很好,所以文件就被创建了。

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

如何在gradle和android studio中包含本地库,在本文中描述:添加预构建。因此,使用android gradle插件的项目中使用的文件是0.7.3 ?

#2


1  

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

这对我来说很有用:https://coderwall.com/p/eurvaq/tesseract- withandoird -gradle。

But do not delete libs directory!

但是不要删除libs目录!

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

将编译版本、buildToolsVersion、minSdkVersion和targetSdkVersio设置为与项目构建相同的值。

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

我还更改类路径的com.android.tools.build:gradle:0.9。+“路径”com.android.tools.build:gradle:1.0 +”。

#3


1  

At some point Android Studio suggests to set jni.srcDirs = []

在某个时候,Android Studio建议设置jni。srcdir =[]

leading to following sourceSets in the gradle.build of my tess-two library project

导致在gradle中有以下的sourceSets。建立我的国际象棋-两个图书馆项目。

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

With correct src path entered here this actualy works

在这里输入正确的src路径,这是实际工作。

#4


0  

I'm not sure if it works for you but in my case, here's what I've done:

我不确定它是否适用于你,但在我的案例中,这是我所做的:

1. In common.h: change #include <allheaders.h> into #include <src/src/allheaders.h>.

2. In the library project build.gradle: add this

sourceSets{
    main {
        manifest.srcFile 'AndroidManifest.xml'
        jni.srcDirs = []
        jniLibs.srcDirs = ['src/main/jniLibs']
        resources.srcDirs = ['src']
        res.srcDirs = ['res']

    }
}

#5


0  

Ppl, After struggling a day.. finally got the solution

在挣扎了一天之后。终于得到了解决

In build.gradle of tess-two module add the below code:

在构建。tess- 2模块的gradle添加以下代码:

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

Main thing is please check manually weather all those file paths specified in above code exists in tess-two module!!

主要问题是,请手动检查以上代码中指定的所有文件路径是否存在于t_ - 2模块中!!

Check in which path "liblept.so" and other ".so" files exist in tess-two library. For me it was inside /tesstwo/src/main/jniLibs/armeabi-v7a . Hence i have made jniLibs.srcDirs = ['src/main/jniLibs'] in above code. Hope it helps !!

检查路径“liblept”。所以“等”。因此,“文件存在于t_ - 2库中”。对我来说,它是在/tesstwo/src/main/jniLibs/armeabi-v7a。因此我做了jniLibs。在上面的代码中,srcDirs = ['src/main/jniLibs']。希望它帮助! !