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

Crashes when having two languages selected #67

Open
rugk opened this issue Aug 1, 2022 · 7 comments
Open

Crashes when having two languages selected #67

rugk opened this issue Aug 1, 2022 · 7 comments

Comments

@rugk
Copy link

rugk commented Aug 1, 2022

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

@redtux
Copy link

redtux commented Sep 4, 2022

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. 😿

@FabulousOne
Copy link

Same happened to me...

@now0clock
Copy link

Still an issue. Same

@RedSteel-1
Copy link

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

@katastrophe92
Copy link

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

@wincentbalin
Copy link
Contributor

wincentbalin commented Jun 23, 2023

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

@operarulez
Copy link

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));
    }
}

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

8 participants