Skip to content

Fix ArrayIndexOutOfBoundsException in MainActivity#209

Draft
cursor[bot] wants to merge 1 commit intomainfrom
arrayindexoutofboundsexception-length1-index2-veispw
Draft

Fix ArrayIndexOutOfBoundsException in MainActivity#209
cursor[bot] wants to merge 1 commit intomainfrom
arrayindexoutofboundsexception-length1-index2-veispw

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 3, 2026

Summary

Fixes ANDROID-E7 - ArrayIndexOutOfBoundsException: length=1; index=2

Changes

  • Changed array size from 1 to 3 in the ArrayIndexOutOfBoundsException button handler
  • This prevents the exception when accessing index 2, as the array now has valid indices 0, 1, and 2

Root Cause

The code was creating a string array with size 1 (valid indices: 0) but attempting to access index 2, which caused an ArrayIndexOutOfBoundsException.

Fix Details

File: app/src/main/java/com/example/vu/android/MainActivity.java
Line: 71

Changed:

String[] strArr = new String[1];

To:

String[] strArr = new String[3];

This ensures that when the code accesses strArr[2], it's within the valid bounds of the array.

Testing

The fix has been verified to be syntactically correct. The array now properly supports access to index 2 without throwing an ArrayIndexOutOfBoundsException.

Open in Web Open in Cursor 

Fixes ANDROID-E7

Changed array size from 1 to 3 to prevent ArrayIndexOutOfBoundsException
when accessing index 2. The array now has valid indices 0, 1, and 2.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (814e302) to head (50d43a9).

Files with missing lines Patch % Lines
...main/java/com/example/vu/android/MainActivity.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #209   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        864     864           
  Branches      65      65           
=====================================
  Misses       864     864           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

1 participant