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

java.lang.IndexOutOfBoundsException: Index: 12, Size: 12 #22

Open
TheOrangeTester opened this issue Jun 17, 2018 · 4 comments
Open

java.lang.IndexOutOfBoundsException: Index: 12, Size: 12 #22

TheOrangeTester opened this issue Jun 17, 2018 · 4 comments

Comments

@TheOrangeTester
Copy link

at java.util.ArrayList.get(ArrayList.java:411)
at com.heinrichreimersoftware.singleinputform.SingleInputFormActivity.getStep(SingleInputFormActivity.java:200)
at com.heinrichreimersoftware.singleinputform.SingleInputFormActivity.getCurrentStep(SingleInputFormActivity.java:196)
at com.heinrichreimersoftware.singleinputform.SingleInputFormActivity.nextStep(SingleInputFormActivity.java:408)
at com.heinrichreimersoftware.singleinputform.SingleInputFormActivity$2.onClick(SingleInputFormActivity.java:100)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22433)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

@ghost
Copy link

ghost commented Aug 5, 2018

this keeps happening whenever you click the finish button it throws indexOutOfBoundException:index: yourStepsSize, size: yourStepsSize (if you have 6 steps it tries to access the 6th element of array of size 6 which doesn't exist)

@Draftdog
Copy link

Draftdog commented Dec 9, 2018

In my SingleInputFormActivity subclass I have added this override:

    @Override
    public void onSaveInstanceState(Bundle outState) {
        // propagating this call to super when the current stepIndex has been incremented to
        // steps.size() by the most recent call to nextStep() will throw an IndexOutOfBoundsException
        // while trying to save the state, it is harmless to simply skip it entirely since
        // everything has already been saved into the bundle
        try {
            getCurrentStep();
        } catch (IndexOutOfBoundsException e) {
            return;
        }

        super.onSaveInstanceState(outState);
    }

It's perfectly harmless to do this check. If you need to save other state then make sure to do it at the start of the method.

(Over here I get the same error while Android attempts to save the activity instance state, you might want to consider doing a similar check in you onClick handler)

@Leepee
Copy link

Leepee commented Apr 20, 2019

Interestingly this doesn't crash my physical device, but emulators and other people I have asked to test my app suffer crashes.

I need to implement the fix that you mention, but I need to work out how to include this library in a way that I can edit. I still don't fully understand what I am doing!

@MatteCarra
Copy link

Do you have any idea how to reproduce this bug?
I can't reproduce it in any way.
I'm working on a pull request, but I can't find out why this bug happens.

Thanks in advance.

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

4 participants