2

I am trying to use the tesseract libray for java in my Android application as suggested here: http://vkedco.blogspot.com/2013/03/vladimir-kulyukin-learning-objectives-1.html

I have followed the instructions as it is and I still get an error that says that I need to have the subfolder tessdata in the path. The subfolder does exist in my sdcard/tesseract_languages folder.

Any suggestions about what I should do to get this running?

Error details are given below:

05-13 20:54:35.653: E/AndroidRuntime(11715): FATAL EXCEPTION: main
05-13 20:54:35.653: E/AndroidRuntime(11715): Process: com.example.msapp2, PID: 11715
05-13 20:54:35.653: E/AndroidRuntime(11715): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.msapp2/com.example.msapp2.MainActivity}: java.lang.IllegalArgumentException: Data path must contain subfolder tessdata!
05-13 20:54:35.653: E/AndroidRuntime(11715):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-13 20:54:35.653: E/AndroidRuntime(11715):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-13 20:54:35.653: E/AndroidRuntime(11715):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-13 20:54:35.653: E/AndroidRuntime(11715):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
2
  • Did you get any solution on this? Commented Jun 19, 2016 at 7:48
  • We have to maintain folder structure according to this. Don't forget to maintain language file inside of this folder Commented Jun 9, 2018 at 18:12

2 Answers 2

2

I met the same issue. When reading the source code, I found:

public boolean init(String datapath, String language) {
        if (datapath == null)
            throw new IllegalArgumentException("Data path must not be null!");
        if (!datapath.endsWith(File.separator))
            datapath += File.separator;

        File tessdata = new File(datapath + "tessdata");
        if (!tessdata.exists() || !tessdata.isDirectory())
            throw new IllegalArgumentException("Data path must contain subfolder tessdata!");

        return nativeInit(datapath, language);
    }

which means don't add "tessdata" to the datapath. The method init() will add it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for advice. I've also read sources and I have omitted this detail.
0

I was facing the same problem. Worked for me when I removed "tessdata" from the path, as yushlx answer.

Before (fail): path = "/mnt/sdcard/tesseract/tessdata"; After (success): path = "/mnt/sdcard/tesseract/";

Of course, tessdata folder should be in the path with the desired.traineddata file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.