I am still confused about how to build a working tess-two Android Studio
project for using Tesseract OCR, despite several posts on it. There is a pre-built version available, whose "Usage" section of the "ReadMe" says we can do this by simply adding tess-two
as an external dependency by just adding the following line to the dependencies
section of our app's build.gradle
:
compile 'com.rmtheis:tess-two:6.0.3'
I understand this tells Android Studio
to fetch the pre-built version of the library from the remote Maven
repository where it has been published, but do we still need to copy across into our fresh new Android Studio
project the contents of the tess-two
directory that we download or clone?
Please see the attached image: My new blank Android Studio project is called TessAndroid. Elsewhere, I have saved the complete tess-two
contents after downloading the zip file. In addition to the compile
line added to the dependencies
section of my app's build.gradle
, do I also have to copy the tess-two folder (or some parts of it) into my main app's root directory?
In addition to the compile line added to the dependencies section of my app's build.gradle, do I also have to copy the tess-two folder (or some parts of it) into my main app's root directory?
No. By adding that compile
line to your build.gradle, you're importing a compiled version of that library's code into your project, and there's no need to also copy its source code into your project.
You can confirm this yourself by creating a new project in Android Studio, adding the compile
line for the library to your new app's build.gradle, and then adding a line of code to your new activity's onCreate
method that references a class in the library:
TessBaseAPI baseApi = new TessBaseAPI();
The class will be found and usable within your project.