Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app crashes when selecting multiple languages #107

Open
TalOrenshtein opened this issue Sep 15, 2023 · 18 comments
Open

app crashes when selecting multiple languages #107

TalOrenshtein opened this issue Sep 15, 2023 · 18 comments

Comments

@TalOrenshtein
Copy link

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

@muchuelo
Copy link

muchuelo commented Sep 21, 2023

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.

@wincentbalin
Copy link
Contributor

Pull request #89 should fix the problem.

@j-lakeman
Copy link

@SubhamTyagi any updates on this?

@hubortje
Copy link

hubortje commented Mar 2, 2024

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

@Thomas-AA
Copy link

Thomas-AA commented Mar 8, 2024

Hi,

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

Android 10 / LineageOS

@deadcombo
Copy link

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.

@T8RIN
Copy link

T8RIN commented Apr 8, 2024

You can use ImageToolbox

@vishalscodes
Copy link

vishalscodes commented Apr 21, 2024

Same problem here. Here's a recording:

YouCut_20240421_140215254.mp4

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

@RedSteel-1
Copy link

Any updates so far?

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

@T8RIN
Copy link

T8RIN commented Jan 9, 2025

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 :)

@RedSteel-1
Copy link

RedSteel-1 commented Jan 9, 2025

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

It only has the option to OCR saved images.
While what is needed (and what the subject program has but it crashes) is OCR directly from the camera. Not from a saved file that was saved only for being OCRed and then either needs to be manually deleted or remains and brings more garbage to the files.

@T8RIN
Copy link

T8RIN commented Jan 9, 2025

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

@T8RIN
Copy link

T8RIN commented Jan 9, 2025

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

@RedSteel-1
Copy link

@T8RIN

Strange, but the only option I see in ImageToolbox's OCR is choosing a file from the filesystem, there is no option for choosing camera..


But anyway the issue is about OCR, and its long-standing and prominent bug that makesthe OCR's usage problematic.

@T8RIN
Copy link

T8RIN commented Jan 9, 2025

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

@j-lakeman
Copy link

@T8RIN pls stop spamming this issue if you have nothing productive to contribute.

@T8RIN
Copy link

T8RIN commented Jan 11, 2025

Lol, i said a way to use the OCR without issues

@j-lakeman
Copy link

Lol half a dozen times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants