android-ocr icon indicating copy to clipboard operation
android-ocr copied to clipboard

app crashes when selecting multiple languages

Open TalOrenshtein opened this issue 1 year ago • 8 comments

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

TalOrenshtein avatar Sep 15 '23 07:09 TalOrenshtein

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.

muchuelo avatar Sep 21 '23 06:09 muchuelo

Pull request #89 should fix the problem.

wincentbalin avatar Oct 16 '23 22:10 wincentbalin

@SubhamTyagi any updates on this?

j-lakeman avatar Nov 07 '23 08:11 j-lakeman

The issue persists with 4.0 (F-Droid) on GrapheneOS.

type: crash
osVersion: google/husky/husky:14/UQ1A.240205.004/2024022800:user/release-keys
package: io.github.subhamtyagi.ocr:12
process: io.github.subhamtyagi.ocr
processUptime: 80 + 204 ms
installer: org.fdroid.fdroid

java.lang.RuntimeException: Unable to start activity ComponentInfo{io.github.subhamtyagi.ocr/io.github.subhamtyagi.ocr.MainActivity}: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 130
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3833)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3974)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2475)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8279)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ExecInit.main(ExecInit.java:49)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 130
	at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
	at java.util.Objects.checkIndex(Objects.java:359)
	at java.util.ArrayList.get(ArrayList.java:434)
	at io.github.subhamtyagi.ocr.MainActivity.t(Unknown Source:8)
	at io.github.subhamtyagi.ocr.MainActivity.s(SourceFile:32)
	at io.github.subhamtyagi.ocr.MainActivity.u(SourceFile:246)
	at io.github.subhamtyagi.ocr.MainActivity.onCreate(SourceFile:246)
	at android.app.Activity.performCreate(Activity.java:8674)
	at android.app.Activity.performCreate(Activity.java:8652)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1461)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3815)
	... 14 more

hubortje avatar Mar 02 '24 08:03 hubortje

Hi,

I experience the same problem. on release 11 & 12 (v4.0) from f-droid.org

Android 10 / LineageOS

Thomas-AA avatar Mar 08 '24 13:03 Thomas-AA

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.

deadcombo avatar Mar 10 '24 17:03 deadcombo

You can use ImageToolbox

T8RIN avatar Apr 08 '24 20:04 T8RIN

Same problem here. Here's a recording:

https://github.com/SubhamTyagi/android-ocr/assets/104351431/c3f9233d-96ad-4f47-b5ee-484c74c1007a

EDIT: Upon testing, @deadcombo's answer works.

vishalscodes avatar Apr 21 '24 08:04 vishalscodes