我该如何为Android平台编译tesseract-4?

时间:2018-03-13 17:39:59

标签: android compiler-errors compilation tesseract

我创建了一个名为*args的项目,然后在项目的根目录中创建了一个名为NDKTest3的文件夹,并将这3个文件放在其中:

Android.mk:

jni

Application.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndktest3
LOCAL_SRC_FILES := test.c
include $(BUILD_SHARED_LIBRARY)
include $(LOCAL_PATH)/../tesseract/android/jni/Android.mk

test.c的:

APP_ABI := all

我还编辑了我的`build.gradle(app),如下所示:

(blank)

settings.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.m.ndktest3"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        ndk{
            moduleName "ndktest3"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild{
        ndkBuild{
            path '../jni/Android.mk'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

然后我将include ':app' include ':tesseract' 文件夹复制到项目的根目录中。您可以在下面看到我的项目:

enter image description here

但是当我想要同步项目时,它会给我这个错误消息:

tesseract

1 个答案:

答案 0 :(得分:0)

  1. 下载/克隆此repo
  2. 输入// tesseract-android / tess / tess-two-master / tess-two
  3. 确保您已下载Android-ndk,如果没有,请下载here
  4. 现在将ndk路径添加到系统路径/环境变量,如果不知道,请检查here
  5. 在该文件夹中,在命令行中输入ndk-build