Skip to content

Latest commit

 

History

History
90 lines (56 loc) · 2.54 KB

BUILDING.md

File metadata and controls

90 lines (56 loc) · 2.54 KB

Building

This project may be built manually as an alternative to including the pre-built AAR as an external dependency in your app project. To start the build, import the root directory of this project into Android Studio as an existing Android Studio project, or follow the instructions below to build on the command line.

Building with Android Studio

The Gradle build uses the gradle-stable plugin and the Android NDK to build the Tesseract and Leptonica native C/C++ code through a call to ndk-build in build.gradle. In Android Studio, use

Build -> Rebuild Project

to build or rebuild the project.

Note: When building from Android Studio, you may need to set the path to your NDK installation in the Project Structure dialog (File->Project Structure).

Building on the Command Line

On Mac/Linux:

Edit your local.properties file to include the path to your NDK directory:

ndk.dir=/path/to/your/android-ndk

Run the following commands:

export ANDROID_HOME=/path/to/your/android-sdk
git clone git://github.com/rmtheis/tess-two tess
cd tess
./gradlew assemble

On Windows:

Edit your local.properties file to include the path to your NDK directory:

ndk.dir=C\:\\path\\to\\your\\android-ndk

Run the following commands:

set ANDROID_HOME=C:\\path\\to\\your\\android-sdk
git clone git://github.com/rmtheis/tess-two tess
cd tess
gradlew assemble

On all above platforms you can build a command-line static banary, e.g.

ndk-build -C tess-two-git/tess-two tesseract APP_ABI=arm64-v8a

It can be deployed to /data/local/tmp of a compatible Android device and run from adb shell:

adb shell time tesseract --tessdata-dir tessdata imagename outputbase

With v.4.1 you can use new or old data files.

Importing

After building, the code that is generated may be imported into your app project in Android Studio as a module using

File -> New -> Import Module -> tess-two folder

and then adding the dependency to your app module build.gradle:

    dependencies {
        implementation project(':tess-two')
    }

Testing

On Mac/Linux:

./preparetests.sh
./gradlew connectedAndroidTest

On Windows:

preparetests.cmd
gradlew connectedAndroidTest

Removing

If you want to remove your app's dependency on the tess-two module, reverse the import process by removing the module using the Project Structure dialog (File->Project Structure), manually deleting the tess-two subfolder from your app project folder, and removing the tess-two reference from your app module build.gradle.