android-ocr: app crashes when selecting multiple languages

Steps to reproduce:

  1. Go to settings
  2. Enable the multiple languages toggle
  3. Select 2 or more languages.

As soon as I confirm the languages, the app crash and refuse to open. Log:

java.lang.RuntimeException: Unable to resume activity {io.github.subhamtyagi.ocr/io.github.subhamtyagi.ocr.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=130; index=-1
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4774)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4807)
	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:179)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=130; index=-1
	at java.util.ArrayList.get(ArrayList.java:439)
	at io.github.subhamtyagi.ocr.MainActivity.t(Unknown Source:8)
	at io.github.subhamtyagi.ocr.MainActivity.onResume(Unknown Source:7)
	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1570)
	at android.app.Activity.performResume(Activity.java:8474)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4764)
	... 13 more

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 18 (1 by maintainers)

Most upvoted comments

You can use ImageToolbox

Idk why this app is needed, when everything but better is already done in ImageToolbox

Also ImageToolbox well maintained, bringing fast support and new features growing rapidly

you are completely mistaken, you can take pictures from the camera (also share directly to the app, pick from gallery, or after edit) and do anything else, you need to look at the possibilities of the app first

Any updates so far?

Been quite a while. And this bug is pretty much prominent

You can use ImageToolbox which has much more OCR possibilities, also there are no crash 😃

Sign-in to GitHub, go to Actions in this repo, open the latest one and download the .apk under Artifacts. You can only download it if you’re logged in.

I have exactly the same problem, except the app does not crash immediately after adding extra languages to the list. But it crashes every time I try to start it if multiple languages are selected.

Uninstalled and reinstalled several times to confirm that selection of multiple languages causes the crash.

After a clean install, the app chooses the default language itself, then successfully downloads the training data, and successfully OCR’s an image of text, but once you go into the settings and change anything (add multiple languages, or even just change Tesseract quality from Fast to Best) the app does not download training data for selected languages, and once closed, will always crash when trying to start the app again.