4

I have been trying to include Tesseract libraries into my Android project today.

From what I have found I did following:

1) Download tess-two from gooogle git, 2) build with NDK 3) put *.so files (armeabi/v7,x86,mips) into /app/main/jniLibs/, 4) pack *.so into .jar file, put archive into app/libs/ and wrote dependency {} to it in gradle.build file

I'm using Android Studio and when I write TessBaseAPI and hit Alt+Enter -> "add dependency to tess-two module" it automaticaly write import row:

import com.googlecode.tesseract.android.TessBaseAPI;

But then when I try to build it I'm getting

error: package com.googlecode.tesseract.android does not exist

I'm using Android Studio 1.1

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Tomáš John
  • 314
  • 4
  • 14
  • This probably means that your IDE does not see the jar. Tesseract used to work ok with the old build system and Eclipse (for Eclipse, one had to mention the dependency in several places). – 18446744073709551615 Mar 21 '16 at 14:26

1 Answers1

8

If somebody would wondering, obviously dependency from alt+enter didn't make it right.

It had to build whole project itself first. So I added a folder:

  • include ':libraries:tess-two'

into the gradle.settings, moving whole project of tess-two structure into 'libraries/tess-two' (when 'libraries' is same level as your 'app' folder).

After that (if you have set up ndk.dir=C:path in local.properties) , you are able to set module dependency into your main project...

Rightclick app->Open Module Settings(or F4) and click plus on right side and add tess-two as module in your project app.

enter image description here

Notice that 'tess-two' folder has to contains own build.gradle (manifestfile and project.properties) file, so it can build itself.

Hope it will helps somebody :)

Tomáš John
  • 314
  • 4
  • 14