Search code examples
tess-two

Not able to initialize tess-two (Could not initialize Tesseract API error)


I wrote a sample Android app. I am getting 'Tesseract(native): Could not initialize Tesseract API with language=eng!' error.

I did include compile 'com.rmtheis:tess-two:5.4.0' in the gradle file Also copied all 'data files' 3.04.00 version to 'tessdata' directory. I debugged Java portion of 'init' code it seems to be working fine, it's failing inside 'nativeside'.

Any suggestions what could be going wrong with my code. Here are few lines of code I am using to init

final String lang = "eng";
TessBaseAPI baseApi = new TessBaseAPI();
File externalDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String externalDirPath = externalDir.getAbsolutePath() + "/";
flag = baseApi.init(externalDirPath, lang);

Solution

  • The problem was not with tess-two, it was with my app, I deployed it on Marshmallow, it requires different way to get WRITE_EXTERNAL_STORAGE permission. I was not aware of it, now I fixed that issue my app is working fine.