本文介绍了在Windows中,tess-two导入android sdk生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在git下载页面中构建了项目竞争步骤 https://github.com/rmtheis/tess-two#build 我已经在路径环境中安装了配置的ndk/sdk,我也有在项目local.properties中添加ndk路径.在我将tess-两个lib作为外部项目添加到我的

I have build the project vie steps in the git download pagehttps://github.com/rmtheis/tess-two#buildI have installed ndk/sdk an configured in my path environment,also i have add ndk path in project local.properties. Here is my project build log, after i had add the tess-two lib as externel project into my

Information:Gradle tasks [clean, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :tesstwo:compileDebugSources, :tesstwo:compileDebugAndroidTestSources]
:app:clean
:tesstwo:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:tesstwo:compileLint
:tesstwo:copyReleaseLint UP-TO-DATE
:tesstwo:mergeReleaseProguardFiles UP-TO-DATE
:tesstwo:preBuild UP-TO-DATE
:tesstwo:preReleaseBuild UP-TO-DATE
:tesstwo:checkReleaseManifest
:tesstwo:prepareReleaseDependencies
:tesstwo:compileReleaseAidl
:tesstwo:compileReleaseRenderscript
:tesstwo:generateReleaseBuildConfig
:tesstwo:generateReleaseAssets UP-TO-DATE
:tesstwo:mergeReleaseAssets
:tesstwo:generateReleaseResValues UP-TO-DATE
:tesstwo:generateReleaseResources
:tesstwo:packageReleaseResources
:tesstwo:processReleaseManifest
:tesstwo:processReleaseResources
:tesstwo:generateReleaseSources
:tesstwo:processReleaseJavaRes UP-TO-DATE
:tesstwo:compileReleaseJava
:tesstwo:packageReleaseJar
:tesstwo:compileReleaseNdk
In file included from C:\Users\Julian\AndroidStudioProjects\Jtess\tesstwo\src\main\jni\com_googlecode_leptonica_android\box.cpp:17:0:
C:\Users\Julian\AndroidStudioProjects\Jtess\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.exe: *** [C:\Users\Julian\AndroidStudioProjects\Jtess\tesstwo\build\intermediates\ndk\release\obj/local/arm64-v8a/objs/tesstwo/C_\Users\Julian\AndroidStudioProjects\Jtess\tesstwo\src\main\jni\com_googlecode_leptonica_android\box.o] Error 1
Error:Execution failed for task ':tesstwo:compileReleaseNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Julian\Downloads\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 38.843 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

推荐答案

您编译Tesseract OCR所遵循的步骤仅在eclipse上有效,如果要在Android Studio上使用它,请按照以下步骤操作

The steps you followed to compile Tesseract OCR works only on eclipse, If you want to use it on Android Studio, follow these steps

2)将该路径添加到系统的环境变量中(例如:"C:\ android_ndk_r10d"),然后重新启动,以便您的计算机可以找到它.

2) Add that path to environment variables of the system (eg: "C:\android_ndk_r10d") and then reboot so your machine can find it.

3)从此处下载"tess-two-master" https://github.com/rmtheis/tess-two ,将其提取(例如,在"C:\")并将其重命名为"tess".

3) Download "tess-two-master" from here https://github.com/rmtheis/tess-two, extract it (for example in "C:\") and rename it in "tess".

4)打开"tess"文件夹,然后打开"tess-two"文件夹.点击一个按住Shift键并选择打开命令"的同时窗口".

4) Open "tess" folder and then open "tess-two" folder. Click on a blank space while pressing the shift button and select "Open command window here".

5)编写"ndk-build",然后等待它完成(大约20分钟).

5) Write "ndk-build" and wait until it completes (about 20min).

6)返回上级文件夹,选择"Eyestwo"文件夹,然后再次选择在按住空格键的同时单击空白处,以便打开命令窗口.

6) Go back in the parent folder, select "eyes-two" folder and again click on a blank space while pressing the shift button in order to open the command window.

7)编写"ndk-build"并等待.

7) Write "ndk-build" and wait.

8)编写"android更新项目–目标1 –路径C:\ tess \ tess-two".的当然,我假设您的"tess"文件夹位于"C:\"

8) Write "android update project –target 1 –path C:\tess\tess-two". Of course I assume your "tess" folder is located in "C:\"

9)写下蚂蚁释放".如果投诉到您要更改的地方系统环境变量(如您在步骤2中所做的那样)并添加新的名称为"JAVA_HOME"的变量,并指定jdk的路径(例如:"C:\ Program Files \ Java \ jdk1.8.0_40")

9) Write "ant release". IF IT COMPLAINS go where you change your system environment variables as you did in step 2 and ADD a new variable with name "JAVA_HOME" and value the path to your jdk (eg: "C:\Program Files\Java\jdk1.8.0_40″)

10)打开一个全新的Android Studio项目,并按照以下说明进行操作指示 https://coderwall.com/p/eurvaq/tesseract-with-andoird-and-gradle 来自使用gradle配置tess-2"部分,但出于安全考虑,请勿删除任何文件夹或文件,即使他建议这样做也是如此.我遇到了麻烦在"libraries \ tess-two"目录中的"build.gradle"文件中,但是足以改变它的一些价值.就我而言,我有:

10) Open a completely new Android Studio project and follow these instructions https://coderwall.com/p/eurvaq/tesseract-with-andoird-and-gradle from section "Configure tess-two with gradle" but for safety don’t delete any folder or file even if he suggests to do so. I had some trouble with "build.gradle" file in "libraries\tess-two" directory, but it is sufficient to change some value on it. In my case I have:

" classpath‘com.android.tools.build:gradle:0.14.0'"代替"classpath‘com.android.tools.build:gradle:0.9.+’"

"

compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}

"

代替

"

compileSdkVersion 19
buildToolsVersion "19.0.3"

defaultConfig {
minSdkVersion 8
targetSdkVersion 19}

".

请注意,最后一步意味着您必须进入文件->项目结构->从左侧子窗口中选择一个模块->依赖关系(最后一个选项卡)->按右侧的绿色"+"->模块依赖性->好"

Note that the last step means you have to go in "File -> Project Structure -> Select a module from the left subwindow -> Dependencies (last tab) ->Press the green "+" on your right -> Module Dependency -> OK"

11)下载此项目 https://github.com/GautamGupta/Simple-Android-OCR 并复制并粘贴在您的新项目中这些文件中的代码:"SimpleAndroidOCRActivity.java","main.xml","strings.xml".当然您的文件可能具有不同的名称(在我的情况下为"MainActivity.java","activity_main.xml","strings.xml"),因此代码中的一些重命名可能是必要的.还要打开"AndroidManifest.xml"并在末尾添加(但在"/清单"之前)您在"/应用程序"和刚刚下载的"AndroidManifest.xml"中的"/manifest"(这意味着您必须添加"uses-permissions"和"uses-feature"标记).

11) Download this project https://github.com/GautamGupta/Simple-Android-OCR and copy&paste in your new project the code in these files: "SimpleAndroidOCRActivity.java", "main.xml", "strings.xml". Of course your files may have different names (in my case "MainActivity.java", "activity_main.xml", "strings.xml") so some renaming in the code may be necessary. Also open your "AndroidManifest.xml" and add at the end (but before "/manifest") what you find between "/application" and "/manifest" in the just downloaded "AndroidManifest.xml" (it means that you have to add "uses-permissions" and "uses-feature" tag).

12)从此处下载 https://code.google.com/p/tesseract-ocr/downloads/list中的文件提取您喜欢的语言(例如:tesseract-ocr-3.02.eng.tar.gz)并找到文件"yourLanguage.traineddata"(例如:"eng.traineddata").暂时忘了打开您的Android Studio IDE项目的文件夹,然后进入"app–> src–> main".在这里创建一个新文件夹,并将其命名为"assets".打开它并创建另一个文件夹名为"tessdata".将您的.traineddata文件放在此处.

12) Download from here https://code.google.com/p/tesseract-ocr/downloads/list the file in the language you prefer (eg: tesseract-ocr-3.02.eng.tar.gz ), extract it and locate the file "yourLanguage.traineddata" (eg: "eng.traineddata"). Forget for a moment your Android Studio IDE, open the folder of your project and go in "app–>src–>main". Create here a new folder and name it "assets". Open it and create another folder named "tessdata". Put there your .traineddata file.

来源: http://gaut.am/making-an-ocr-android-app-using-tesseract/#comment-184181

这篇关于在Windows中,tess-two导入android sdk生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 16:03