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

Crashes when having two languages selected

Open rugk opened this issue 2 years ago • 7 comments

STR

  1. Open app, configure.
  2. Choose to allow multiple languages in the settings.
  3. Select German and English.

what happens

At the next start/going to main screen the app crashes.

FATAL EXCEPTION: main
Process: io.github.subhamtyagi.ocr, PID: 25329
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.github.subhamtyagi.ocr/io.github.subhamtyagi.ocr.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=130; index=-1
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3707)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
	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:7870)
	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:1003)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=130; index=-1
	at java.util.ArrayList.get(ArrayList.java:439)
	at io.github.subhamtyagi.ocr.MainActivity.y(Unknown Source:8)
	at io.github.subhamtyagi.ocr.MainActivity.x(Unknown Source:31)
	at io.github.subhamtyagi.ocr.MainActivity.z(:15)
	at io.github.subhamtyagi.ocr.MainActivity.onCreate(:4)
	at android.app.Activity.performCreate(Activity.java:8057)
	at android.app.Activity.performCreate(Activity.java:8037)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1345)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688)
	... 12 more

what should happen

No crash.

system

Device: Pixel 4 (flame)
OS: Android 12, CalyxOS 3.6.0
source: F-Droid
version: v3.2 Build-ID: SQ3A.220605.009.A1.22306002

rugk avatar Aug 01 '22 09:08 rugk

Thanks for reporting this, I can confirm the bug. Just wanted to report it as well, and then found this issue. 👍

As described, the app only crashes when selecting multiple languages and does not start again until deleting all data. 😿

redtux avatar Sep 04 '22 13:09 redtux

Same happened to me...

FabulousOne avatar Mar 12 '23 17:03 FabulousOne

Still an issue. Same

now0clock avatar Apr 11 '23 19:04 now0clock

The same :-/ Opened settings, chose some languages, and now impossible to launch, crashes on every attempt.

RedSteel-1 avatar Apr 25 '23 16:04 RedSteel-1

I have the loop open app-crash app still also when having multiple languages selected

katastrophe92 avatar Jun 09 '23 12:06 katastrophe92

I confirm the crash as described above too. Also, this issue is a duplicate of the issue #40.

wincentbalin avatar Jun 23 '23 22:06 wincentbalin

That works:

private String getLanguageNameFromCode(String code) {
    if (code.contains("+")) {
        String[] lang_codes = code.split("\\+");
        StringBuilder rLanguageName = new StringBuilder();
        for (String lang : lang_codes) {
            rLanguageName.append(languagesNames.get(languagesCodes.indexOf(lang)));
            rLanguageName.append("+");
        }
        return rLanguageName.subSequence(0, rLanguageName.toString().lastIndexOf('+')).toString();
    } else {
        return languagesNames.get(languagesCodes.indexOf(code));
    }
}

operarulez avatar Jul 29 '23 22:07 operarulez